From 731cfa1c9d392791a25f1a5a1cb36007e46facad Mon Sep 17 00:00:00 2001 From: Subhash Bhushan Date: Wed, 8 May 2024 10:57:27 -0700 Subject: [PATCH] Replace flake8 + black + isort with `ruff` (#411) ruff is a single tool and acts as a drop-in replacement for all these tools. It's config is in one place, in pyproject.toml. And it's blazing fast! This commit also removes tox and depends on GitHub actions for multi-env testing. Fixes #410 --- .cookiecutterrc | 53 ---- .editorconfig | 22 -- .flake8 | 20 -- .pre-commit-config.yaml | 29 +-- docs_src/guides/domain-definition/009.py | 2 +- poetry.lock | 231 ++---------------- pyproject.toml | 18 +- src/protean/__init__.py | 30 +++ src/protean/__main__.py | 1 + src/protean/adapters/broker/celery.py | 6 +- src/protean/adapters/cache/__init__.py | 3 +- src/protean/adapters/email/__init__.py | 1 - src/protean/adapters/email/dummy.py | 1 + src/protean/adapters/email/sendgrid.py | 3 +- src/protean/adapters/repository/__init__.py | 2 +- src/protean/adapters/repository/memory.py | 2 +- src/protean/adapters/repository/sqlalchemy.py | 1 - src/protean/cli/__init__.py | 2 +- src/protean/cli/shell.py | 16 +- src/protean/core/aggregate.py | 1 + src/protean/core/event_sourced_aggregate.py | 6 +- src/protean/core/serializer.py | 1 + src/protean/core/view.py | 1 + src/protean/domain/__init__.py | 2 +- src/protean/domain/registry.py | 6 +- src/protean/fields/__init__.py | 23 ++ src/protean/fields/base.py | 1 - src/protean/fields/basic.py | 2 +- src/protean/fields/validators.py | 1 + src/protean/port/__init__.py | 2 + src/protean/server/__init__.py | 2 + src/protean/utils/__init__.py | 3 +- src/protean/utils/inflection.py | 2 +- src/protean/utils/query.py | 1 + tests/adapters/broker/celery_broker/tests.py | 2 +- .../message_db_event_store/tests.py | 18 +- .../elasticsearch_repo/test_provider.py | 1 + .../postgresql/test_provider.py | 1 + .../sqlalchemy_repo/sqlite/test_provider.py | 1 + tests/conftest.py | 3 +- tests/domain/tests.py | 1 - tests/event/tests.py | 19 +- tests/field/test_field_types.py | 2 +- tests/field/test_field_validators.py | 3 +- tests/field/tests.py | 2 +- tests/query/test_queryset.py | 3 +- tests/value_object/elements.py | 2 +- .../value_object/test_vo_custom_validators.py | 2 +- tox.ini | 89 ------- 49 files changed, 160 insertions(+), 486 deletions(-) delete mode 100644 .cookiecutterrc delete mode 100644 .editorconfig delete mode 100644 .flake8 delete mode 100644 tox.ini diff --git a/.cookiecutterrc b/.cookiecutterrc deleted file mode 100644 index a9deb6f6..00000000 --- a/.cookiecutterrc +++ /dev/null @@ -1,53 +0,0 @@ -# This file exists so you can easily regenerate your project. -# -# `cookiepatcher` is a convenient shim around `cookiecutter` -# for regenerating projects (it will generate a .cookiecutterrc -# automatically for any template). To use it: -# -# pip install cookiepatcher -# cookiepatcher gh:ionelmc/cookiecutter-pylibrary project-path -# -# See: -# https://pypi.python.org/pypi/cookiepatcher -# -# Alternatively, you can run: -# -# cookiecutter --overwrite-if-exists --config-file=project-path/.cookiecutterrc gh:ionelmc/cookiecutter-pylibrary - -default_context: - - _template: 'gh:ionelmc/cookiecutter-pylibrary' - appveyor: 'no' - c_extension_function: 'longest' - c_extension_module: '_protean' - c_extension_optional: 'no' - c_extension_support: 'no' - codacy: 'no' - codeclimate: 'no' - codecov: 'no' - command_line_interface: 'click' - command_line_interface_bin_name: 'protean' - coveralls: 'no' - distribution_name: 'protean' - email: 'subhash@team8solutions.com' - full_name: 'Subhash Bhushan C' - github_username: 'proteanhq' - landscape: 'no' - license: 'BSD 3-Clause License' - linter: 'flake8' - package_name: 'protean' - project_name: 'Protean' - project_short_description: 'Protean Application Framework' - release_date: 'today' - repo_name: 'protean' - requiresio: 'no' - scrutinizer: 'no' - sphinx_doctest: 'no' - sphinx_theme: 'alabaster' - test_matrix_configurator: 'no' - test_matrix_separate_coverage: 'no' - test_runner: 'pytest' - travis: 'no' - version: '0.0.1' - website: 'https://protean.readthedocs.io/' - year: 'now' diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index cbdfe491..00000000 --- a/.editorconfig +++ /dev/null @@ -1,22 +0,0 @@ -# see http://editorconfig.org -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[*.{yaml,yml}] -indent_size = 2 - -[*.{bat,cmd,ps1}] -end_of_line = crlf - -[*.py] -max_line_length = 119 - -[docs-sphinx/**.rst] -max_line_length = 119 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 74f46851..00000000 --- a/.flake8 +++ /dev/null @@ -1,20 +0,0 @@ -[flake8] -max-line-length = 119 -max-doc-length = 119 -extend-ignore = E731, E203 -per-file-ignores = __init__.py:F401 -exclude = - .tox, - .git, - __pycache__, - docs-sphinx/source/conf.py, - build, - dist, - conftest.py, - *.pyc, - *.egg-info, - .cache, - .eggs -max-complexity = 10 -import-order-style = google -application-import-names = flake8 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 184e7d6a..8734090d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,10 @@ repos: - - repo: https://github.com/psf/black - rev: 24.2.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.4.3 hooks: - - id: black - language_version: python3 - - - repo: git@github.com:PyCQA/autoflake.git - rev: v2.3.1 - hooks: - - id: autoflake - args: - [ - "--in-place", - "--remove-all-unused-imports", - "--ignore-init-module-imports", - ] - - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - args: ["--profile", "black", "--filter-files", "--quiet"] + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format diff --git a/docs_src/guides/domain-definition/009.py b/docs_src/guides/domain-definition/009.py index c52a754c..4233b8c5 100644 --- a/docs_src/guides/domain-definition/009.py +++ b/docs_src/guides/domain-definition/009.py @@ -7,7 +7,7 @@ class EmailValidator: def __init__(self): - self.error = f"Invalid email address" + self.error = "Invalid email address" def __call__(self, value): """Business rules of Email address""" diff --git a/poetry.lock b/poetry.lock index 06d25b99..bca34dae 100644 --- a/poetry.lock +++ b/poetry.lock @@ -62,20 +62,6 @@ six = ">=1.12.0" astroid = ["astroid (>=1,<2)", "astroid (>=2,<4)"] test = ["astroid (>=1,<2)", "astroid (>=2,<4)", "pytest"] -[[package]] -name = "autoflake" -version = "2.3.1" -description = "Removes unused imports and unused variables" -optional = false -python-versions = ">=3.8" -files = [ - {file = "autoflake-2.3.1-py3-none-any.whl", hash = "sha256:3ae7495db9084b7b32818b4140e6dc4fc280b712fb414f5b8fe57b0a8e85a840"}, - {file = "autoflake-2.3.1.tar.gz", hash = "sha256:c98b75dc5b0a86459c4f01a1d32ac7eb4338ec4317a4469515ff1e687ecd909e"}, -] - -[package.dependencies] -pyflakes = ">=3.0.0" - [[package]] name = "babel" version = "2.14.0" @@ -115,50 +101,6 @@ files = [ [package.dependencies] chardet = ">=3.0.2" -[[package]] -name = "black" -version = "24.3.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-24.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7d5e026f8da0322b5662fa7a8e752b3fa2dac1c1cbc213c3d7ff9bdd0ab12395"}, - {file = "black-24.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9f50ea1132e2189d8dff0115ab75b65590a3e97de1e143795adb4ce317934995"}, - {file = "black-24.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2af80566f43c85f5797365077fb64a393861a3730bd110971ab7a0c94e873e7"}, - {file = "black-24.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:4be5bb28e090456adfc1255e03967fb67ca846a03be7aadf6249096100ee32d0"}, - {file = "black-24.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4f1373a7808a8f135b774039f61d59e4be7eb56b2513d3d2f02a8b9365b8a8a9"}, - {file = "black-24.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:aadf7a02d947936ee418777e0247ea114f78aff0d0959461057cae8a04f20597"}, - {file = "black-24.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65c02e4ea2ae09d16314d30912a58ada9a5c4fdfedf9512d23326128ac08ac3d"}, - {file = "black-24.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:bf21b7b230718a5f08bd32d5e4f1db7fc8788345c8aea1d155fc17852b3410f5"}, - {file = "black-24.3.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:2818cf72dfd5d289e48f37ccfa08b460bf469e67fb7c4abb07edc2e9f16fb63f"}, - {file = "black-24.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4acf672def7eb1725f41f38bf6bf425c8237248bb0804faa3965c036f7672d11"}, - {file = "black-24.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7ed6668cbbfcd231fa0dc1b137d3e40c04c7f786e626b405c62bcd5db5857e4"}, - {file = "black-24.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:56f52cfbd3dabe2798d76dbdd299faa046a901041faf2cf33288bc4e6dae57b5"}, - {file = "black-24.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:79dcf34b33e38ed1b17434693763301d7ccbd1c5860674a8f871bd15139e7837"}, - {file = "black-24.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e19cb1c6365fd6dc38a6eae2dcb691d7d83935c10215aef8e6c38edee3f77abd"}, - {file = "black-24.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65b76c275e4c1c5ce6e9870911384bff5ca31ab63d19c76811cb1fb162678213"}, - {file = "black-24.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:b5991d523eee14756f3c8d5df5231550ae8993e2286b8014e2fdea7156ed0959"}, - {file = "black-24.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c45f8dff244b3c431b36e3224b6be4a127c6aca780853574c00faf99258041eb"}, - {file = "black-24.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6905238a754ceb7788a73f02b45637d820b2f5478b20fec82ea865e4f5d4d9f7"}, - {file = "black-24.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7de8d330763c66663661a1ffd432274a2f92f07feeddd89ffd085b5744f85e7"}, - {file = "black-24.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:7bb041dca0d784697af4646d3b62ba4a6b028276ae878e53f6b4f74ddd6db99f"}, - {file = "black-24.3.0-py3-none-any.whl", hash = "sha256:41622020d7120e01d377f74249e677039d20e6344ff5851de8a10f11f513bf93"}, - {file = "black-24.3.0.tar.gz", hash = "sha256:a0c9c4a0771afc6919578cec71ce82a3e31e054904e7197deacbc9382671c41f"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=0.9.0" -platformdirs = ">=2" - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "bleach" version = "6.1.0" @@ -210,17 +152,6 @@ test = ["filelock (>=3)", "pytest (>=6.2.4)", "pytest-cov (>=2.12)", "pytest-moc typing = ["importlib-metadata (>=5.1)", "mypy (>=1.5.0,<1.6.0)", "tomli", "typing-extensions (>=3.7.4.3)"] virtualenv = ["virtualenv (>=20.0.35)"] -[[package]] -name = "cachetools" -version = "5.3.3" -description = "Extensible memoizing collections and decorators" -optional = false -python-versions = ">=3.7" -files = [ - {file = "cachetools-5.3.3-py3-none-any.whl", hash = "sha256:0abad1021d3f8325b2fc1d2e9c8b9c9d57b04c3932657a72465447332c24d945"}, - {file = "cachetools-5.3.3.tar.gz", hash = "sha256:ba29e2dfa0b8b556606f097407ed1aa62080ee108ab0dc5ec9d6a723a007d105"}, -] - [[package]] name = "celery" version = "5.2.7" @@ -858,22 +789,6 @@ docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1 testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] typing = ["typing-extensions (>=4.8)"] -[[package]] -name = "flake8" -version = "7.0.0" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-7.0.0-py2.py3-none-any.whl", hash = "sha256:a6dfbb75e03252917f2473ea9653f7cd799c3064e54d4c8140044c5c065f53c3"}, - {file = "flake8-7.0.0.tar.gz", hash = "sha256:33f96621059e65eec474169085dc92bf26e7b2d47366b70be2f67ab80dc25132"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.11.0,<2.12.0" -pyflakes = ">=3.2.0,<3.3.0" - [[package]] name = "flask" version = "3.0.2" @@ -1098,20 +1013,6 @@ qtconsole = ["qtconsole"] test = ["pickleshare", "pytest (<8)", "pytest-asyncio (<0.22)", "testpath"] test-extra = ["curio", "ipython[test]", "matplotlib (!=3.2.0)", "nbformat", "numpy (>=1.23)", "pandas", "trio"] -[[package]] -name = "isort" -version = "5.13.2" -description = "A Python utility / library to sort Python imports." -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, - {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, -] - -[package.extras] -colors = ["colorama (>=0.4.6)"] - [[package]] name = "itsdangerous" version = "2.1.2" @@ -1406,17 +1307,6 @@ files = [ [package.dependencies] traitlets = "*" -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] - [[package]] name = "mdurl" version = "0.1.2" @@ -1566,17 +1456,6 @@ files = [ {file = "more_itertools-10.2.0-py3-none-any.whl", hash = "sha256:686b06abe565edfab151cb8fd385a05651e1fdf8f0a14191e4439283421f8684"}, ] -[[package]] -name = "mypy-extensions" -version = "1.0.0" -description = "Type system extensions for programs checked with the mypy type checker." -optional = false -python-versions = ">=3.5" -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] - [[package]] name = "nh3" version = "0.2.15" @@ -1819,17 +1698,6 @@ files = [ [package.extras] tests = ["pytest"] -[[package]] -name = "pycodestyle" -version = "2.11.1" -description = "Python style guide checker" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"}, - {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"}, -] - [[package]] name = "pycparser" version = "2.21" @@ -1951,17 +1819,6 @@ files = [ [package.dependencies] typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" -[[package]] -name = "pyflakes" -version = "3.2.0" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, - {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, -] - [[package]] name = "pygments" version = "2.17.2" @@ -1995,24 +1852,6 @@ pyyaml = "*" [package.extras] extra = ["pygments (>=2.12)"] -[[package]] -name = "pyproject-api" -version = "1.6.1" -description = "API to interact with the python pyproject.toml based projects" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pyproject_api-1.6.1-py3-none-any.whl", hash = "sha256:4c0116d60476b0786c88692cf4e325a9814965e2469c5998b830bba16b183675"}, - {file = "pyproject_api-1.6.1.tar.gz", hash = "sha256:1817dc018adc0d1ff9ca1ed8c60e1623d5aaca40814b953af14a9cf9a5cae538"}, -] - -[package.dependencies] -packaging = ">=23.1" - -[package.extras] -docs = ["furo (>=2023.8.19)", "sphinx (<7.2)", "sphinx-autodoc-typehints (>=1.24)"] -testing = ["covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "setuptools (>=68.1.2)", "wheel (>=0.41.2)"] - [[package]] name = "pyproject-hooks" version = "1.0.0" @@ -2080,21 +1919,6 @@ pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] -[[package]] -name = "pytest-flake8" -version = "1.1.1" -description = "pytest plugin to check FLAKE8 requirements" -optional = false -python-versions = "*" -files = [ - {file = "pytest-flake8-1.1.1.tar.gz", hash = "sha256:ba4f243de3cb4c2486ed9e70752c80dd4b636f7ccb27d4eba763c35ed0cd316e"}, - {file = "pytest_flake8-1.1.1-py2.py3-none-any.whl", hash = "sha256:e0661a786f8cbf976c185f706fdaf5d6df0b1667c3bcff8e823ba263618627e7"}, -] - -[package.dependencies] -flake8 = ">=4.0" -pytest = ">=7.0" - [[package]] name = "pytest-mock" version = "3.12.0" @@ -2224,7 +2048,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -2520,6 +2343,32 @@ pygments = ">=2.13.0,<3.0.0" [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] +[[package]] +name = "ruff" +version = "0.4.3" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.4.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b70800c290f14ae6fcbb41bbe201cf62dfca024d124a1f373e76371a007454ce"}, + {file = "ruff-0.4.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:08a0d6a22918ab2552ace96adeaca308833873a4d7d1d587bb1d37bae8728eb3"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eba1f14df3c758dd7de5b55fbae7e1c8af238597961e5fb628f3de446c3c40c5"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:819fb06d535cc76dfddbfe8d3068ff602ddeb40e3eacbc90e0d1272bb8d97113"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0bfc9e955e6dc6359eb6f82ea150c4f4e82b660e5b58d9a20a0e42ec3bb6342b"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:510a67d232d2ebe983fddea324dbf9d69b71c4d2dfeb8a862f4a127536dd4cfb"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dc9ff11cd9a092ee7680a56d21f302bdda14327772cd870d806610a3503d001f"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:29efff25bf9ee685c2c8390563a5b5c006a3fee5230d28ea39f4f75f9d0b6f2f"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18b00e0bcccf0fc8d7186ed21e311dffd19761cb632241a6e4fe4477cc80ef6e"}, + {file = "ruff-0.4.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:262f5635e2c74d80b7507fbc2fac28fe0d4fef26373bbc62039526f7722bca1b"}, + {file = "ruff-0.4.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:7363691198719c26459e08cc17c6a3dac6f592e9ea3d2fa772f4e561b5fe82a3"}, + {file = "ruff-0.4.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:eeb039f8428fcb6725bb63cbae92ad67b0559e68b5d80f840f11914afd8ddf7f"}, + {file = "ruff-0.4.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:927b11c1e4d0727ce1a729eace61cee88a334623ec424c0b1c8fe3e5f9d3c865"}, + {file = "ruff-0.4.3-py3-none-win32.whl", hash = "sha256:25cacda2155778beb0d064e0ec5a3944dcca9c12715f7c4634fd9d93ac33fd30"}, + {file = "ruff-0.4.3-py3-none-win_amd64.whl", hash = "sha256:7a1c3a450bc6539ef00da6c819fb1b76b6b065dec585f91456e7c0d6a0bbc725"}, + {file = "ruff-0.4.3-py3-none-win_arm64.whl", hash = "sha256:71ca5f8ccf1121b95a59649482470c5601c60a416bf189d553955b0338e34614"}, + {file = "ruff-0.4.3.tar.gz", hash = "sha256:ff0a3ef2e3c4b6d133fbedcf9586abfbe38d076041f2dc18ffb2c7e0485d5a07"}, +] + [[package]] name = "secretstorage" version = "3.3.3" @@ -2707,32 +2556,6 @@ files = [ {file = "text_unidecode-1.3-py2.py3-none-any.whl", hash = "sha256:1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8"}, ] -[[package]] -name = "tox" -version = "4.14.2" -description = "tox is a generic virtualenv management and test command line tool" -optional = false -python-versions = ">=3.8" -files = [ - {file = "tox-4.14.2-py3-none-any.whl", hash = "sha256:2900c4eb7b716af4a928a7fdc2ed248ad6575294ed7cfae2ea41203937422847"}, - {file = "tox-4.14.2.tar.gz", hash = "sha256:0defb44f6dafd911b61788325741cc6b2e12ea71f987ac025ad4d649f1f1a104"}, -] - -[package.dependencies] -cachetools = ">=5.3.2" -chardet = ">=5.2" -colorama = ">=0.4.6" -filelock = ">=3.13.1" -packaging = ">=23.2" -platformdirs = ">=4.1" -pluggy = ">=1.3" -pyproject-api = ">=1.6.1" -virtualenv = ">=20.25" - -[package.extras] -docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-argparse-cli (>=1.11.1)", "sphinx-autodoc-typehints (>=1.25.2)", "sphinx-copybutton (>=0.5.2)", "sphinx-inline-tabs (>=2023.4.21)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.11)"] -testing = ["build[virtualenv] (>=1.0.3)", "covdefaults (>=2.3)", "detect-test-pollution (>=1.2)", "devpi-process (>=1)", "diff-cover (>=8.0.2)", "distlib (>=0.3.8)", "flaky (>=3.7)", "hatch-vcs (>=0.4)", "hatchling (>=1.21)", "psutil (>=5.9.7)", "pytest (>=7.4.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-xdist (>=3.5)", "re-assert (>=1.1)", "time-machine (>=2.13)", "wheel (>=0.42)"] - [[package]] name = "traitlets" version = "5.14.2" @@ -3022,4 +2845,4 @@ sqlite = ["sqlalchemy"] [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "936553a3c16c13681275becf254db46184201116262d7774b31fb8a356e5cac7" +content-hash = "507426e9290b84bbf96c7b90da0f0cdbd904d5d607fbca34a2427c24eca95527" diff --git a/pyproject.toml b/pyproject.toml index 52744ac3..34a46a14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,6 @@ celery = { version = "~5.2.7", extras = ["redis"], optional = true} flask = {version = ">=1.1.1", optional = true} sendgrid = {version = ">=6.1.3", optional = true} message-db-py = {version = ">=0.2.0", optional = true} -tox = "^4.14.1" [tool.poetry.extras] elasticsearch = ["elasticsearch", "elasticsearch-dsl"] @@ -92,25 +91,21 @@ sendgrid = ["sendgrid"] optional = true [tool.poetry.group.dev.dependencies] -black = ">=23.11.0" check-manifest = ">=0.49" coverage = ">=7.3.2" docutils = ">=0.20.1" pre-commit = ">=2.16.0" -tox = ">=4.14.1" +ruff = "^0.4.3" twine = ">=4.0.2" [tool.poetry.group.test] optional = true [tool.poetry.group.test.dependencies] -autoflake = ">=2.2.1" -isort = ">=5.12.0" mock = "5.1.0" pluggy = "1.3.0" pytest-asyncio = ">=0.21.1" pytest-cov = ">=4.1.0" -pytest-flake8 = ">=1.1.1" pytest-mock = "3.12.0" pytest = ">=7.4.3" @@ -163,14 +158,3 @@ markers = [ "eventstore", "no_test_domain", ] - -[tool.isort] -balanced_wrapping = true -force_grid_wrap = 0 -include_trailing_comma = true -known_first_party = ["protean", "tests"] -line_length = 88 -multi_line_output = 3 -lines_between_types = 1 -order_by_type = true -use_parentheses = true \ No newline at end of file diff --git a/src/protean/__init__.py b/src/protean/__init__.py index 266db4f3..c5ba12db 100644 --- a/src/protean/__init__.py +++ b/src/protean/__init__.py @@ -24,3 +24,33 @@ from .server import Engine from .utils import get_version from .utils.mixins import handle + +__all__ = [ + "BaseAggregate", + "BaseApplicationService", + "BaseCommand", + "BaseCommandHandler", + "BaseDomainService", + "BaseEmail", + "BaseEntity", + "BaseEvent", + "BaseEventHandler", + "BaseEventSourcedAggregate", + "BaseModel", + "BaseRepository", + "BaseSerializer", + "BaseSubscriber", + "BaseValueObject", + "BaseView", + "Config", + "Domain", + "Engine", + "Q", + "QuerySet", + "UnitOfWork", + "apply", + "current_domain", + "current_uow", + "get_version", + "handle", +] diff --git a/src/protean/__main__.py b/src/protean/__main__.py index e20c8814..4ba70996 100644 --- a/src/protean/__main__.py +++ b/src/protean/__main__.py @@ -8,6 +8,7 @@ - https://docs.python.org/2/using/cmdline.html#cmdoption-m - https://docs.python.org/3/using/cmdline.html#cmdoption-m """ + from protean.cli import main if __name__ == "__main__": diff --git a/src/protean/adapters/broker/celery.py b/src/protean/adapters/broker/celery.py index 8391b4c7..98167cd5 100644 --- a/src/protean/adapters/broker/celery.py +++ b/src/protean/adapters/broker/celery.py @@ -90,9 +90,9 @@ def register(self, initiator_cls, consumer_cls): "{self.celery_app.tasks} as Celery Task" ) else: - self._command_handlers[ - fully_qualified_name(initiator) - ] = decorated_cls_instance + self._command_handlers[fully_qualified_name(initiator)] = ( + decorated_cls_instance + ) def publish(self, message: Message) -> None: event_cls = fetch_element_cls_from_registry( diff --git a/src/protean/adapters/cache/__init__.py b/src/protean/adapters/cache/__init__.py index d2709cc9..67117289 100644 --- a/src/protean/adapters/cache/__init__.py +++ b/src/protean/adapters/cache/__init__.py @@ -1,4 +1,5 @@ -""" Package for Concrete Implementations of Protean repositories """ +"""Package for Concrete Implementations of Protean repositories""" + import collections import importlib import logging diff --git a/src/protean/adapters/email/__init__.py b/src/protean/adapters/email/__init__.py index 4470fdc0..505aff4c 100644 --- a/src/protean/adapters/email/__init__.py +++ b/src/protean/adapters/email/__init__.py @@ -2,7 +2,6 @@ import logging from protean.exceptions import ConfigurationError -from protean.globals import current_uow logger = logging.getLogger(__name__) diff --git a/src/protean/adapters/email/dummy.py b/src/protean/adapters/email/dummy.py index d8debd11..3ba17251 100644 --- a/src/protean/adapters/email/dummy.py +++ b/src/protean/adapters/email/dummy.py @@ -1,4 +1,5 @@ """A Dummy Email Provider class""" + import logging from protean.core.email import BaseEmailProvider diff --git a/src/protean/adapters/email/sendgrid.py b/src/protean/adapters/email/sendgrid.py index de2fbea7..d8aecf4e 100644 --- a/src/protean/adapters/email/sendgrid.py +++ b/src/protean/adapters/email/sendgrid.py @@ -1,4 +1,5 @@ -""" Define the send-grid email provider """ +"""Define the send-grid email provider""" + import logging from python_http_client.exceptions import HTTPError diff --git a/src/protean/adapters/repository/__init__.py b/src/protean/adapters/repository/__init__.py index 1f91c256..c8f5f3aa 100644 --- a/src/protean/adapters/repository/__init__.py +++ b/src/protean/adapters/repository/__init__.py @@ -1,4 +1,4 @@ -""" Package for Concrete Implementations of Protean repositories """ +"""Package for Concrete Implementations of Protean repositories""" import collections import importlib diff --git a/src/protean/adapters/repository/memory.py b/src/protean/adapters/repository/memory.py index cf5b3217..0cd0b4d3 100644 --- a/src/protean/adapters/repository/memory.py +++ b/src/protean/adapters/repository/memory.py @@ -1,4 +1,4 @@ -"""Implementation of a dictionary based repository """ +"""Implementation of a dictionary based repository""" import copy import json diff --git a/src/protean/adapters/repository/sqlalchemy.py b/src/protean/adapters/repository/sqlalchemy.py index 93996736..9e750526 100644 --- a/src/protean/adapters/repository/sqlalchemy.py +++ b/src/protean/adapters/repository/sqlalchemy.py @@ -162,7 +162,6 @@ def field_mapping_for(field_obj: Field): # Upgrade to Postgresql specific Data Types if cls.metadata.bind.dialect.name == "postgresql": - if field_cls == Dict and not field_obj.pickled: sa_type_cls = psql.JSON diff --git a/src/protean/cli/__init__.py b/src/protean/cli/__init__.py index 47792ca0..e3412e1a 100644 --- a/src/protean/cli/__init__.py +++ b/src/protean/cli/__init__.py @@ -76,7 +76,7 @@ def main( def test( category: Annotated[ Category, typer.Option("-c", "--category", case_sensitive=False) - ] = Category.CORE + ] = Category.CORE, ): commands = ["pytest", "--cache-clear", "--ignore=tests/support/"] diff --git a/src/protean/cli/shell.py b/src/protean/cli/shell.py index 22dfd63b..7c293867 100644 --- a/src/protean/cli/shell.py +++ b/src/protean/cli/shell.py @@ -1,14 +1,14 @@ """Run an interactive Python shell in the context of a given - Protean domain. The domain will populate the default - namespace of this shell according to its configuration. +Protean domain. The domain will populate the default +namespace of this shell according to its configuration. - This is useful for executing small snippets of code - without having to manually configure the application. +This is useful for executing small snippets of code +without having to manually configure the application. - FIXME: Populate context in a decorator like Flask does: - https://github.com/pallets/flask/blob/b90a4f1f4a370e92054b9cc9db0efcb864f87ebe/src/flask/cli.py#L368 - https://github.com/pallets/flask/blob/b90a4f1f4a370e92054b9cc9db0efcb864f87ebe/src/flask/cli.py#L984 - """ +FIXME: Populate context in a decorator like Flask does: + https://github.com/pallets/flask/blob/b90a4f1f4a370e92054b9cc9db0efcb864f87ebe/src/flask/cli.py#L368 + https://github.com/pallets/flask/blob/b90a4f1f4a370e92054b9cc9db0efcb864f87ebe/src/flask/cli.py#L984 +""" import logging import sys diff --git a/src/protean/core/aggregate.py b/src/protean/core/aggregate.py index 9a6835a2..03ada138 100644 --- a/src/protean/core/aggregate.py +++ b/src/protean/core/aggregate.py @@ -1,4 +1,5 @@ """Aggregate Functionality and Classes""" + import logging from protean.container import EventedMixin diff --git a/src/protean/core/event_sourced_aggregate.py b/src/protean/core/event_sourced_aggregate.py index 05e1d26d..87dca84c 100644 --- a/src/protean/core/event_sourced_aggregate.py +++ b/src/protean/core/event_sourced_aggregate.py @@ -176,9 +176,9 @@ def event_sourced_aggregate_factory(element_cls, **opts): element_cls._projections[fully_qualified_name(method._event_cls)].add( method ) - element_cls._events_cls_map[ - fully_qualified_name(method._event_cls) - ] = method._event_cls + element_cls._events_cls_map[fully_qualified_name(method._event_cls)] = ( + method._event_cls + ) # Associate Event with the aggregate class if inspect.isclass(method._event_cls) and issubclass( diff --git a/src/protean/core/serializer.py b/src/protean/core/serializer.py index c2e4ebee..dd2e50d7 100644 --- a/src/protean/core/serializer.py +++ b/src/protean/core/serializer.py @@ -1,4 +1,5 @@ """Serializer Object Functionality and Classes""" + import logging from marshmallow import Schema, fields diff --git a/src/protean/core/view.py b/src/protean/core/view.py index 4e8c8db0..74beef3c 100644 --- a/src/protean/core/view.py +++ b/src/protean/core/view.py @@ -1,4 +1,5 @@ """View Functionality and Classes""" + import logging from protean.container import BaseContainer, OptionsMixin diff --git a/src/protean/domain/__init__.py b/src/protean/domain/__init__.py index 3165f19f..e51904bf 100644 --- a/src/protean/domain/__init__.py +++ b/src/protean/domain/__init__.py @@ -8,7 +8,7 @@ from collections import defaultdict from functools import lru_cache -from typing import Any, Callable, Dict, List, Optional, Union +from typing import Any, Callable, Dict, List, Optional from werkzeug.datastructures import ImmutableDict diff --git a/src/protean/domain/registry.py b/src/protean/domain/registry.py index ee97bc1a..e96b4912 100644 --- a/src/protean/domain/registry.py +++ b/src/protean/domain/registry.py @@ -95,9 +95,9 @@ def register_element(self, element_cls): cls=element_cls, ) - self._elements[element_cls.element_type.value][ - element_name - ] = element_record + self._elements[element_cls.element_type.value][element_name] = ( + element_record + ) # Create an array to hold multiple elements of same name if element_cls.__name__ in self._elements_by_name: diff --git a/src/protean/fields/__init__.py b/src/protean/fields/__init__.py index eb627434..5e7c2022 100644 --- a/src/protean/fields/__init__.py +++ b/src/protean/fields/__init__.py @@ -17,3 +17,26 @@ Text, ) from .embedded import ValueObject + +__all__ = [ + "Auto", + "Boolean", + "Date", + "DateTime", + "Dict", + "Field", + "FieldBase", + "Float", + "HasMany", + "HasOne", + "Identifier", + "Integer", + "List", + "Method", + "Nested", + "Reference", + "String", + "Text", + "ValueObject", + "validators", +] diff --git a/src/protean/fields/base.py b/src/protean/fields/base.py index 55fe90a8..4bd368f7 100644 --- a/src/protean/fields/base.py +++ b/src/protean/fields/base.py @@ -64,7 +64,6 @@ def __init__( validators: Iterable = (), error_messages: dict = None, ): - # Pass to FieldDescriptorMixin for initialization super().__init__(referenced_as=referenced_as, description=description) diff --git a/src/protean/fields/basic.py b/src/protean/fields/basic.py index 5cbd408b..9c4c17dd 100644 --- a/src/protean/fields/basic.py +++ b/src/protean/fields/basic.py @@ -1,4 +1,4 @@ -""" Module for defining basic Field types of Entity """ +"""Module for defining basic Field types of Entity""" import datetime diff --git a/src/protean/fields/validators.py b/src/protean/fields/validators.py index e74bd58b..9c43ff43 100644 --- a/src/protean/fields/validators.py +++ b/src/protean/fields/validators.py @@ -1,4 +1,5 @@ """Module for defining different validators used by Field Types""" + import re from protean.exceptions import ValidationError diff --git a/src/protean/port/__init__.py b/src/protean/port/__init__.py index 0f6f9a27..a0279612 100644 --- a/src/protean/port/__init__.py +++ b/src/protean/port/__init__.py @@ -3,3 +3,5 @@ from .dao import BaseDAO from .event_store import BaseEventStore from .provider import BaseProvider + +__all__ = ["BaseBroker", "BaseCache", "BaseDAO", "BaseEventStore", "BaseProvider"] diff --git a/src/protean/server/__init__.py b/src/protean/server/__init__.py index c2fcbb1a..17243b35 100644 --- a/src/protean/server/__init__.py +++ b/src/protean/server/__init__.py @@ -1 +1,3 @@ from .engine import Engine + +__all__ = ["Engine"] diff --git a/src/protean/utils/__init__.py b/src/protean/utils/__init__.py index be2dffe7..2929fac2 100644 --- a/src/protean/utils/__init__.py +++ b/src/protean/utils/__init__.py @@ -3,6 +3,7 @@ Definitions/declaractions in this module should be independent of other modules, to the maximum extent possible. """ + import functools import importlib import logging @@ -12,7 +13,7 @@ from typing import Any, Tuple, Union from uuid import uuid4 -from protean.exceptions import ConfigurationError, IncorrectUsageError +from protean.exceptions import ConfigurationError from protean.globals import current_domain logger = logging.getLogger(__name__) diff --git a/src/protean/utils/inflection.py b/src/protean/utils/inflection.py index 9c2ecc45..ae5c48aa 100644 --- a/src/protean/utils/inflection.py +++ b/src/protean/utils/inflection.py @@ -1,4 +1,4 @@ -""" Utilities for converting names between different cases""" +"""Utilities for converting names between different cases""" import re diff --git a/src/protean/utils/query.py b/src/protean/utils/query.py index d778e9b6..6b90cd72 100644 --- a/src/protean/utils/query.py +++ b/src/protean/utils/query.py @@ -1,4 +1,5 @@ """Utility classes and methods for DB Adapters, Repositories and Query Constructors""" + import copy import functools import inspect diff --git a/tests/adapters/broker/celery_broker/tests.py b/tests/adapters/broker/celery_broker/tests.py index 553e7ea2..acc98863 100644 --- a/tests/adapters/broker/celery_broker/tests.py +++ b/tests/adapters/broker/celery_broker/tests.py @@ -35,4 +35,4 @@ def register(self): def test_that_an_event_is_published_to_the_broker(self, mock): Person.add_newcomer({"first_name": "John", "last_name": "Doe", "age": 21}) mock.assert_called_once() - assert type(mock.call_args.args[0]) is dict + assert isinstance(mock.call_args.args[0], dict) diff --git a/tests/adapters/event_store/message_db_event_store/tests.py b/tests/adapters/event_store/message_db_event_store/tests.py index 87e3aaf0..3e634807 100644 --- a/tests/adapters/event_store/message_db_event_store/tests.py +++ b/tests/adapters/event_store/message_db_event_store/tests.py @@ -14,12 +14,12 @@ def test_retrieving_message_store_from_domain(self, test_domain): def test_error_on_message_db_initialization(self): domain = Domain(__file__) - domain.config["EVENT_STORE"][ - "PROVIDER" - ] = "protean.adapters.event_store.message_db.MessageDBStore" - domain.config["EVENT_STORE"][ - "DATABASE_URI" - ] = "postgresql://message_store@localhost:5433/dummy" + domain.config["EVENT_STORE"]["PROVIDER"] = ( + "protean.adapters.event_store.message_db.MessageDBStore" + ) + domain.config["EVENT_STORE"]["DATABASE_URI"] = ( + "postgresql://message_store@localhost:5433/dummy" + ) with pytest.raises(ConfigurationError) as exc: domain.event_store.store._write( @@ -29,9 +29,9 @@ def test_error_on_message_db_initialization(self): assert 'FATAL: database "dummy" does not exist' in str(exc.value) # Reset config value. # FIXME Config should be an argument to the domain - domain.config["EVENT_STORE"][ - "PROVIDER" - ] = "protean.adapters.event_store.memory.MemoryEventStore" + domain.config["EVENT_STORE"]["PROVIDER"] = ( + "protean.adapters.event_store.memory.MemoryEventStore" + ) domain.config["EVENT_STORE"].pop("DATABASE_URI") def test_write_to_event_store(self, test_domain): diff --git a/tests/adapters/repository/elasticsearch_repo/test_provider.py b/tests/adapters/repository/elasticsearch_repo/test_provider.py index 9bce6ef6..990a3116 100644 --- a/tests/adapters/repository/elasticsearch_repo/test_provider.py +++ b/tests/adapters/repository/elasticsearch_repo/test_provider.py @@ -1,4 +1,5 @@ """Module to test SQLAlchemy Provider Class""" + import pytest from elasticsearch import Elasticsearch diff --git a/tests/adapters/repository/sqlalchemy_repo/postgresql/test_provider.py b/tests/adapters/repository/sqlalchemy_repo/postgresql/test_provider.py index de871b6b..1676a206 100644 --- a/tests/adapters/repository/sqlalchemy_repo/postgresql/test_provider.py +++ b/tests/adapters/repository/sqlalchemy_repo/postgresql/test_provider.py @@ -1,4 +1,5 @@ """Module to test SQLAlchemy Provider Class""" + import pytest from sqlalchemy.engine.result import Result diff --git a/tests/adapters/repository/sqlalchemy_repo/sqlite/test_provider.py b/tests/adapters/repository/sqlalchemy_repo/sqlite/test_provider.py index 412e54cd..c1c14440 100644 --- a/tests/adapters/repository/sqlalchemy_repo/sqlite/test_provider.py +++ b/tests/adapters/repository/sqlalchemy_repo/sqlite/test_provider.py @@ -1,4 +1,5 @@ """Module to test SQLAlchemy Provider Class""" + import pytest from sqlalchemy.engine.result import Result diff --git a/tests/conftest.py b/tests/conftest.py index 2be978ad..af70e373 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,6 @@ """Module to setup Factories and other required artifacts for tests - isort:skip_file +isort:skip_file """ import os @@ -224,7 +224,6 @@ def db(test_domain): @pytest.fixture(autouse=True) def run_around_tests(test_domain): - yield if test_domain: diff --git a/tests/domain/tests.py b/tests/domain/tests.py index 2a51c50d..8186e484 100644 --- a/tests/domain/tests.py +++ b/tests/domain/tests.py @@ -19,7 +19,6 @@ def test_that_a_domain_can_be_initialized_successfully(self): class TestDomainRegistration: def test_that_only_recognized_element_types_can_be_registered(self, test_domain): - with pytest.raises(NotImplementedError): test_domain.registry.register_element(UserFoo) diff --git a/tests/event/tests.py b/tests/event/tests.py index 78460821..c919db6c 100644 --- a/tests/event/tests.py +++ b/tests/event/tests.py @@ -41,17 +41,14 @@ class UserAdded(BaseEvent): email = ValueObject(Email, required=True) name = String(max_length=50) - assert ( - UserAdded( - { - "email": { - "address": "john.doe@gmail.com", - }, - "name": "John Doe", - } - ) - == UserAdded(email_address="john.doe@gmail.com", name="John Doe") - ) + assert UserAdded( + { + "email": { + "address": "john.doe@gmail.com", + }, + "name": "John Doe", + } + ) == UserAdded(email_address="john.doe@gmail.com", name="John Doe") class TestDomainEventInitialization: diff --git a/tests/field/test_field_types.py b/tests/field/test_field_types.py index f050f4f0..fe56adab 100644 --- a/tests/field/test_field_types.py +++ b/tests/field/test_field_types.py @@ -1,4 +1,4 @@ -""" Test cases for all available field type implementations""" +"""Test cases for all available field type implementations""" import enum diff --git a/tests/field/test_field_validators.py b/tests/field/test_field_validators.py index 57822dc0..3a41ad02 100644 --- a/tests/field/test_field_validators.py +++ b/tests/field/test_field_validators.py @@ -1,4 +1,5 @@ -""" Test cases for validators""" +"""Test cases for validators""" + import re import pytest diff --git a/tests/field/tests.py b/tests/field/tests.py index a4b35952..94d58dd4 100644 --- a/tests/field/tests.py +++ b/tests/field/tests.py @@ -15,7 +15,7 @@ class DummyStringField(Field): def _cast_to_type(self, value: str): """Value must me a string type""" - if type(value) is not str: + if not isinstance(value, str): self.fail("invalid_type") return value diff --git a/tests/query/test_queryset.py b/tests/query/test_queryset.py index 60072deb..72b2d13e 100644 --- a/tests/query/test_queryset.py +++ b/tests/query/test_queryset.py @@ -1,4 +1,5 @@ -""" Test the Q object used for managing filter criteria """ +"""Test the Q object used for managing filter criteria""" + import pytest from protean import QuerySet diff --git a/tests/value_object/elements.py b/tests/value_object/elements.py index 42282399..5b0c6f1b 100644 --- a/tests/value_object/elements.py +++ b/tests/value_object/elements.py @@ -30,7 +30,7 @@ def from_address(cls, address): def validate(cls, address): """Business rules of Email address""" if ( - type(address) is not str + not isinstance(address, str) or "@" not in address or address.count("@") > 1 or len(address) > 255 diff --git a/tests/value_object/test_vo_custom_validators.py b/tests/value_object/test_vo_custom_validators.py index 00f759ba..c89ebe5d 100644 --- a/tests/value_object/test_vo_custom_validators.py +++ b/tests/value_object/test_vo_custom_validators.py @@ -8,7 +8,7 @@ class EmailValidator: def __init__(self): - self.error = f"Invalid email address" + self.error = "Invalid email address" def __call__(self, value): """Business rules of Email address""" diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 8c99f7b2..00000000 --- a/tox.ini +++ /dev/null @@ -1,89 +0,0 @@ -; a generative tox configuration, see: https://tox.readthedocs.io/en/latest/config.html#generative-envlist - -[tox] -envlist = - clean, - check, - py37, - report, - docs -skip_missing_interpreters = True - -[testenv] -basepython = - {py37,docs,spell}: {env:TOXPYTHON:python3.7} - {bootstrap,clean,check,report,coveralls,codecov}: {env:TOXPYTHON:python3} -setenv = - PYTHONPATH={toxinidir}/tests - PYTHONUNBUFFERED=yes -passenv = - * -usedevelop = false -deps = -rrequirements/test.txt -commands = - {posargs:pytest --slow --cov --cov-report=term-missing -vv tests} - -[testenv:bootstrap] -deps = - jinja2 - matrix -skip_install = true -commands = - python ci/bootstrap.py -[testenv:spell] -setenv = - SPELLCHECK=1 -commands = - sphinx-build -b spelling docs-sphinx docs-sphinx/docs -skip_install = true -deps = - -r{toxinidir}/docs-sphinx/requirements.txt - sphinxcontrib-spelling - pyenchant - -[testenv:docs] -deps = - -r{toxinidir}/docs-sphinx/requirements.txt -commands = - sphinx-build {posargs:-E} -b html docs-sphinx dist/docs-sphinx - sphinx-build -b linkcheck docs-sphinx dist/docs-sphinx - -[testenv:check] -deps = - docutils - flake8 - readme-renderer - pygments - isort -skip_install = true -commands = - flake8 src tests - isort --atomic src tests - -[testenv:coveralls] -deps = - coveralls -skip_install = true -commands = - coveralls [] - -[testenv:codecov] -deps = - codecov -skip_install = true -commands = - coverage xml --ignore-errors - codecov [] - -[testenv:report] -deps = coverage -skip_install = true -commands = - coverage combine --append - coverage report - coverage html - -[testenv:clean] -commands = coverage erase -skip_install = true -deps = coverage