From 5bc7d8424875f1ed6bcc7bc79cee12f8e38b0501 Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Tue, 6 Feb 2024 14:26:53 +0100 Subject: [PATCH 01/13] Transfer pydocstyle rules to ruff --- .flake8 | 7 +- .pre-commit-config.yaml | 29 +++--- poetry.lock | 221 +++++++++++++++++----------------------- pyproject.toml | 21 +++- 4 files changed, 130 insertions(+), 148 deletions(-) diff --git a/.flake8 b/.flake8 index 5cda42b8..32658f7c 100644 --- a/.flake8 +++ b/.flake8 @@ -1,6 +1,6 @@ [flake8] -extend-ignore = E501,E402,W503,E203,D213,D203,DOC301,DOC502 +extend-ignore = E501,E402,W503,E203,DOC301,DOC502 exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,cue.mod docstring-convention = all style = sphinx @@ -9,7 +9,4 @@ arg-type-hints-in-signature = True arg-type-hints-in-docstring = False # Ignore documentation linting in tests per-file-ignores = - tests/**: D101, D102, D103, D200, D202, D205, D212, D121, D400, D401, D403, D404, D415, DOC - # Since click uses a different layout for the docs strings to generate the - # cli docs, we ignore these rules here. - src/pixelator/cli/**: D200, D212, D400, D415 + tests/**: DOC diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 45a2fb31..ea3e4a03 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,9 +5,9 @@ repos: rev: v4.4.0 hooks: - id: check-yaml - exclude: '^(conda-recipe)/(.*)$' + exclude: "^(conda-recipe)/(.*)$" - id: end-of-file-fixer - exclude: '^(.*)/webreport/template.html$' + exclude: "^(.*)/webreport/template.html$" - id: trailing-whitespace - repo: https://github.com/psf/black @@ -16,25 +16,24 @@ repos: - id: black - repo: https://github.com/pycqa/flake8 - rev: '6.0.0' # pick a git hash / tag to point to + rev: "6.0.0" # pick a git hash / tag to point to hooks: - id: flake8 additional_dependencies: - - pydocstyle - flake8-docstrings - pydoclint - repo: https://github.com/charliermarsh/ruff-pre-commit # Ruff version. - rev: 'v0.0.261' + rev: "v0.2.1" hooks: - id: ruff - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.3.0' # Use the sha / tag you want to point at + rev: "v1.3.0" # Use the sha / tag you want to point at hooks: - id: mypy - exclude: '(^cue.mod/)|(^docs/)' + exclude: "(^cue.mod/)|(^docs/)" additional_dependencies: - numpy - types-requests @@ -48,11 +47,11 @@ repos: - repo: local hooks: - - id: copyright-checker - name: Copyright notice checker - description: Checks that there is a copyright header in all files - entry: ./utils/check_copyright.py - language: python - pass_filenames: true - types: [file, python] - exclude: '^(docs)/(.*)$' + - id: copyright-checker + name: Copyright notice checker + description: Checks that there is a copyright header in all files + entry: ./utils/check_copyright.py + language: python + pass_filenames: true + types: [file, python] + exclude: "^(docs)/(.*)$" diff --git a/poetry.lock b/poetry.lock index 34d9bfb9..7667dbce 100644 --- a/poetry.lock +++ b/poetry.lock @@ -973,77 +973,62 @@ mccabe = ">=0.7.0,<0.8.0" pycodestyle = ">=2.11.0,<2.12.0" pyflakes = ">=3.2.0,<3.3.0" -[[package]] -name = "flake8-docstrings" -version = "1.7.0" -description = "Extension for flake8 which uses pydocstyle to check docstrings" -optional = false -python-versions = ">=3.7" -files = [ - {file = "flake8_docstrings-1.7.0-py2.py3-none-any.whl", hash = "sha256:51f2344026da083fc084166a9353f5082b01f72901df422f74b4d953ae88ac75"}, - {file = "flake8_docstrings-1.7.0.tar.gz", hash = "sha256:4c8cc748dc16e6869728699e5d0d685da9a10b0ea718e090b1ba088e67a941af"}, -] - -[package.dependencies] -flake8 = ">=3" -pydocstyle = ">=2.1" - [[package]] name = "fonttools" -version = "4.47.2" +version = "4.48.1" description = "Tools to manipulate font files" optional = false python-versions = ">=3.8" files = [ - {file = "fonttools-4.47.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3b629108351d25512d4ea1a8393a2dba325b7b7d7308116b605ea3f8e1be88df"}, - {file = "fonttools-4.47.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c19044256c44fe299d9a73456aabee4b4d06c6b930287be93b533b4737d70aa1"}, - {file = "fonttools-4.47.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b8be28c036b9f186e8c7eaf8a11b42373e7e4949f9e9f370202b9da4c4c3f56c"}, - {file = "fonttools-4.47.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f83a4daef6d2a202acb9bf572958f91cfde5b10c8ee7fb1d09a4c81e5d851fd8"}, - {file = "fonttools-4.47.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4a5a5318ba5365d992666ac4fe35365f93004109d18858a3e18ae46f67907670"}, - {file = "fonttools-4.47.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8f57ecd742545362a0f7186774b2d1c53423ed9ece67689c93a1055b236f638c"}, - {file = "fonttools-4.47.2-cp310-cp310-win32.whl", hash = "sha256:a1c154bb85dc9a4cf145250c88d112d88eb414bad81d4cb524d06258dea1bdc0"}, - {file = "fonttools-4.47.2-cp310-cp310-win_amd64.whl", hash = "sha256:3e2b95dce2ead58fb12524d0ca7d63a63459dd489e7e5838c3cd53557f8933e1"}, - {file = "fonttools-4.47.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:29495d6d109cdbabe73cfb6f419ce67080c3ef9ea1e08d5750240fd4b0c4763b"}, - {file = "fonttools-4.47.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0a1d313a415eaaba2b35d6cd33536560deeebd2ed758b9bfb89ab5d97dc5deac"}, - {file = "fonttools-4.47.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:90f898cdd67f52f18049250a6474185ef6544c91f27a7bee70d87d77a8daf89c"}, - {file = "fonttools-4.47.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3480eeb52770ff75140fe7d9a2ec33fb67b07efea0ab5129c7e0c6a639c40c70"}, - {file = "fonttools-4.47.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0255dbc128fee75fb9be364806b940ed450dd6838672a150d501ee86523ac61e"}, - {file = "fonttools-4.47.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f791446ff297fd5f1e2247c188de53c1bfb9dd7f0549eba55b73a3c2087a2703"}, - {file = "fonttools-4.47.2-cp311-cp311-win32.whl", hash = "sha256:740947906590a878a4bde7dd748e85fefa4d470a268b964748403b3ab2aeed6c"}, - {file = "fonttools-4.47.2-cp311-cp311-win_amd64.whl", hash = "sha256:63fbed184979f09a65aa9c88b395ca539c94287ba3a364517698462e13e457c9"}, - {file = "fonttools-4.47.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:4ec558c543609e71b2275c4894e93493f65d2f41c15fe1d089080c1d0bb4d635"}, - {file = "fonttools-4.47.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:e040f905d542362e07e72e03612a6270c33d38281fd573160e1003e43718d68d"}, - {file = "fonttools-4.47.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6dd58cc03016b281bd2c74c84cdaa6bd3ce54c5a7f47478b7657b930ac3ed8eb"}, - {file = "fonttools-4.47.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:32ab2e9702dff0dd4510c7bb958f265a8d3dd5c0e2547e7b5f7a3df4979abb07"}, - {file = "fonttools-4.47.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:3a808f3c1d1df1f5bf39be869b6e0c263570cdafb5bdb2df66087733f566ea71"}, - {file = "fonttools-4.47.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:ac71e2e201df041a2891067dc36256755b1229ae167edbdc419b16da78732c2f"}, - {file = "fonttools-4.47.2-cp312-cp312-win32.whl", hash = "sha256:69731e8bea0578b3c28fdb43dbf95b9386e2d49a399e9a4ad736b8e479b08085"}, - {file = "fonttools-4.47.2-cp312-cp312-win_amd64.whl", hash = "sha256:b3e1304e5f19ca861d86a72218ecce68f391646d85c851742d265787f55457a4"}, - {file = "fonttools-4.47.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:254d9a6f7be00212bf0c3159e0a420eb19c63793b2c05e049eb337f3023c5ecc"}, - {file = "fonttools-4.47.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:eabae77a07c41ae0b35184894202305c3ad211a93b2eb53837c2a1143c8bc952"}, - {file = "fonttools-4.47.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a86a5ab2873ed2575d0fcdf1828143cfc6b977ac448e3dc616bb1e3d20efbafa"}, - {file = "fonttools-4.47.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13819db8445a0cec8c3ff5f243af6418ab19175072a9a92f6cc8ca7d1452754b"}, - {file = "fonttools-4.47.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:4e743935139aa485fe3253fc33fe467eab6ea42583fa681223ea3f1a93dd01e6"}, - {file = "fonttools-4.47.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d49ce3ea7b7173faebc5664872243b40cf88814ca3eb135c4a3cdff66af71946"}, - {file = "fonttools-4.47.2-cp38-cp38-win32.whl", hash = "sha256:94208ea750e3f96e267f394d5588579bb64cc628e321dbb1d4243ffbc291b18b"}, - {file = "fonttools-4.47.2-cp38-cp38-win_amd64.whl", hash = "sha256:0f750037e02beb8b3569fbff701a572e62a685d2a0e840d75816592280e5feae"}, - {file = "fonttools-4.47.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:3d71606c9321f6701642bd4746f99b6089e53d7e9817fc6b964e90d9c5f0ecc6"}, - {file = "fonttools-4.47.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:86e0427864c6c91cf77f16d1fb9bf1bbf7453e824589e8fb8461b6ee1144f506"}, - {file = "fonttools-4.47.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a00bd0e68e88987dcc047ea31c26d40a3c61185153b03457956a87e39d43c37"}, - {file = "fonttools-4.47.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a5d77479fb885ef38a16a253a2f4096bc3d14e63a56d6246bfdb56365a12b20c"}, - {file = "fonttools-4.47.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:5465df494f20a7d01712b072ae3ee9ad2887004701b95cb2cc6dcb9c2c97a899"}, - {file = "fonttools-4.47.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4c811d3c73b6abac275babb8aa439206288f56fdb2c6f8835e3d7b70de8937a7"}, - {file = "fonttools-4.47.2-cp39-cp39-win32.whl", hash = "sha256:5b60e3afa9635e3dfd3ace2757039593e3bd3cf128be0ddb7a1ff4ac45fa5a50"}, - {file = "fonttools-4.47.2-cp39-cp39-win_amd64.whl", hash = "sha256:7ee48bd9d6b7e8f66866c9090807e3a4a56cf43ffad48962725a190e0dd774c8"}, - {file = "fonttools-4.47.2-py3-none-any.whl", hash = "sha256:7eb7ad665258fba68fd22228a09f347469d95a97fb88198e133595947a20a184"}, - {file = "fonttools-4.47.2.tar.gz", hash = "sha256:7df26dd3650e98ca45f1e29883c96a0b9f5bb6af8d632a6a108bc744fa0bd9b3"}, + {file = "fonttools-4.48.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:702ae93058c81f46461dc4b2c79f11d3c3d8fd7296eaf8f75b4ba5bbf813cd5f"}, + {file = "fonttools-4.48.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:97f0a49fa6aa2d6205c6f72f4f98b74ef4b9bfdcb06fd78e6fe6c7af4989b63e"}, + {file = "fonttools-4.48.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d3260db55f1843e57115256e91247ad9f68cb02a434b51262fe0019e95a98738"}, + {file = "fonttools-4.48.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e740a7602c2bb71e1091269b5dbe89549749a8817dc294b34628ffd8b2bf7124"}, + {file = "fonttools-4.48.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4108b1d247953dd7c90ec8f457a2dec5fceb373485973cc852b14200118a51ee"}, + {file = "fonttools-4.48.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:56339ec557f0c342bddd7c175f5e41c45fc21282bee58a86bd9aa322bec715f2"}, + {file = "fonttools-4.48.1-cp310-cp310-win32.whl", hash = "sha256:bff5b38d0e76eb18e0b8abbf35d384e60b3371be92f7be36128ee3e67483b3ec"}, + {file = "fonttools-4.48.1-cp310-cp310-win_amd64.whl", hash = "sha256:f7449493886da6a17472004d3818cc050ba3f4a0aa03fb47972e4fa5578e6703"}, + {file = "fonttools-4.48.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:18b35fd1a850ed7233a99bbd6774485271756f717dac8b594958224b54118b61"}, + {file = "fonttools-4.48.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cad5cfd044ea2e306fda44482b3dd32ee47830fa82dfa4679374b41baa294f5f"}, + {file = "fonttools-4.48.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6f30e605c7565d0da6f0aec75a30ec372072d016957cd8fc4469721a36ea59b7"}, + {file = "fonttools-4.48.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aee76fd81a8571c68841d6ef0da750d5ff08ff2c5f025576473016f16ac3bcf7"}, + {file = "fonttools-4.48.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:5057ade278e67923000041e2b195c9ea53e87f227690d499b6a4edd3702f7f01"}, + {file = "fonttools-4.48.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:b10633aafc5932995a391ec07eba5e79f52af0003a1735b2306b3dab8a056d48"}, + {file = "fonttools-4.48.1-cp311-cp311-win32.whl", hash = "sha256:0d533f89819f9b3ee2dbedf0fed3825c425850e32bdda24c558563c71be0064e"}, + {file = "fonttools-4.48.1-cp311-cp311-win_amd64.whl", hash = "sha256:d20588466367f05025bb1efdf4e5d498ca6d14bde07b6928b79199c588800f0a"}, + {file = "fonttools-4.48.1-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0a2417547462e468edf35b32e3dd06a6215ac26aa6316b41e03b8eeaf9f079ea"}, + {file = "fonttools-4.48.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:cf5a0cd974f85a80b74785db2d5c3c1fd6cc09a2ba3c837359b2b5da629ee1b0"}, + {file = "fonttools-4.48.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0452fcbfbce752ba596737a7c5ec5cf76bc5f83847ce1781f4f90eab14ece252"}, + {file = "fonttools-4.48.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:578c00f93868f64a4102ecc5aa600a03b49162c654676c3fadc33de2ddb88a81"}, + {file = "fonttools-4.48.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:63dc592a16cd08388d8c4c7502b59ac74190b23e16dfc863c69fe1ea74605b68"}, + {file = "fonttools-4.48.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:9b58638d8a85e3a1b32ec0a91d9f8171a877b4b81c408d4cb3257d0dee63e092"}, + {file = "fonttools-4.48.1-cp312-cp312-win32.whl", hash = "sha256:d10979ef14a8beaaa32f613bb698743f7241d92f437a3b5e32356dfb9769c65d"}, + {file = "fonttools-4.48.1-cp312-cp312-win_amd64.whl", hash = "sha256:cdfd7557d1bd294a200bd211aa665ca3b02998dcc18f8211a5532da5b8fad5c5"}, + {file = "fonttools-4.48.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:3cdb9a92521b81bf717ebccf592bd0292e853244d84115bfb4db0c426de58348"}, + {file = "fonttools-4.48.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9b4ec6d42a7555f5ae35f3b805482f0aad0f1baeeef54859492ea3b782959d4a"}, + {file = "fonttools-4.48.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:902e9c4e9928301912f34a6638741b8ae0b64824112b42aaf240e06b735774b1"}, + {file = "fonttools-4.48.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a8c8b54bd1420c184a995f980f1a8076f87363e2bb24239ef8c171a369d85a31"}, + {file = "fonttools-4.48.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:12ee86abca46193359ea69216b3a724e90c66ab05ab220d39e3fc068c1eb72ac"}, + {file = "fonttools-4.48.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6978bade7b6c0335095bdd0bd97f8f3d590d2877b370f17e03e0865241694eb5"}, + {file = "fonttools-4.48.1-cp38-cp38-win32.whl", hash = "sha256:bcd77f89fc1a6b18428e7a55dde8ef56dae95640293bfb8f4e929929eba5e2a2"}, + {file = "fonttools-4.48.1-cp38-cp38-win_amd64.whl", hash = "sha256:f40441437b039930428e04fb05ac3a132e77458fb57666c808d74a556779e784"}, + {file = "fonttools-4.48.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:0d2b01428f7da26f229a5656defc824427b741e454b4e210ad2b25ed6ea2aed4"}, + {file = "fonttools-4.48.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:df48798f9a4fc4c315ab46e17873436c8746f5df6eddd02fad91299b2af7af95"}, + {file = "fonttools-4.48.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2eb4167bde04e172a93cf22c875d8b0cff76a2491f67f5eb069566215302d45d"}, + {file = "fonttools-4.48.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c900508c46274d32d308ae8e82335117f11aaee1f7d369ac16502c9a78930b0a"}, + {file = "fonttools-4.48.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:594206b31c95fcfa65f484385171fabb4ec69f7d2d7f56d27f17db26b7a31814"}, + {file = "fonttools-4.48.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:292922dc356d7f11f5063b4111a8b719efb8faea92a2a88ed296408d449d8c2e"}, + {file = "fonttools-4.48.1-cp39-cp39-win32.whl", hash = "sha256:4709c5bf123ba10eac210d2d5c9027d3f472591d9f1a04262122710fa3d23199"}, + {file = "fonttools-4.48.1-cp39-cp39-win_amd64.whl", hash = "sha256:63c73b9dd56a94a3cbd2f90544b5fca83666948a9e03370888994143b8d7c070"}, + {file = "fonttools-4.48.1-py3-none-any.whl", hash = "sha256:e3e33862fc5261d46d9aae3544acb36203b1a337d00bdb5d3753aae50dac860e"}, + {file = "fonttools-4.48.1.tar.gz", hash = "sha256:8b8a45254218679c7f1127812761e7854ed5c8e34349aebf581e8c9204e7495a"}, ] [package.extras] -all = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "fs (>=2.2.0,<3)", "lxml (>=4.0,<5)", "lz4 (>=1.7.4.2)", "matplotlib", "munkres", "pycairo", "scipy", "skia-pathops (>=0.5.0)", "sympy", "uharfbuzz (>=0.23.0)", "unicodedata2 (>=15.1.0)", "xattr", "zopfli (>=0.1.4)"] +all = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "fs (>=2.2.0,<3)", "lxml (>=4.0)", "lz4 (>=1.7.4.2)", "matplotlib", "munkres", "pycairo", "scipy", "skia-pathops (>=0.5.0)", "sympy", "uharfbuzz (>=0.23.0)", "unicodedata2 (>=15.1.0)", "xattr", "zopfli (>=0.1.4)"] graphite = ["lz4 (>=1.7.4.2)"] interpolatable = ["munkres", "pycairo", "scipy"] -lxml = ["lxml (>=4.0,<5)"] +lxml = ["lxml (>=4.0)"] pathops = ["skia-pathops (>=0.5.0)"] plot = ["matplotlib"] repacker = ["uharfbuzz (>=0.23.0)"] @@ -2573,23 +2558,6 @@ typing-extensions = ">=4.2.0" dotenv = ["python-dotenv (>=0.10.4)"] email = ["email-validator (>=1.0.3)"] -[[package]] -name = "pydocstyle" -version = "6.3.0" -description = "Python docstring style checker" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pydocstyle-6.3.0-py3-none-any.whl", hash = "sha256:118762d452a49d6b05e194ef344a55822987a462831ade91ec5c06fd2169d019"}, - {file = "pydocstyle-6.3.0.tar.gz", hash = "sha256:7ce43f0c0ac87b07494eb9c0b462c0b73e6ff276807f204d6b53edc72b7e44e1"}, -] - -[package.dependencies] -snowballstemmer = ">=2.2.0" - -[package.extras] -toml = ["tomli (>=1.2.3)"] - [[package]] name = "pyfastx" version = "2.0.2" @@ -3213,27 +3181,28 @@ files = [ [[package]] name = "ruff" -version = "0.0.244" -description = "An extremely fast Python linter, written in Rust." +version = "0.2.1" +description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.0.244-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:5d65a0adffa51314cf9f1036c51dbcde0462b23b49a3d8e3a696a221f9f46f54"}, - {file = "ruff-0.0.244-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:3d6bf5094f2c447f5ff8d10c670dc1bc8b7f70cb5f4e43afe1d0624b934c1284"}, - {file = "ruff-0.0.244-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c0f54790b297d5df8120a348c91426a0375c40f62880d30438e46922399b29bf"}, - {file = "ruff-0.0.244-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:88e263e3d7267b4b10f5c1fc1446c5d6b47824c6d78e5c3a97ef79c83d9cb837"}, - {file = "ruff-0.0.244-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8044c79098e3f2deaf970ab468bf5661b193163369bfe5bbda636e6363aa7932"}, - {file = "ruff-0.0.244-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:258e5e3386a8efdff9f253395cc03a3a88204442ac8db50aeb0a529e2862d57b"}, - {file = "ruff-0.0.244-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bd09c523aeed4d81f358093dc4df384a4db42ff5f9627c9506c26c2becbe19a7"}, - {file = "ruff-0.0.244-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c98f0d4a4e052e8b0e27b47e83563026d749b07a21a097780cd283c2f885ad3c"}, - {file = "ruff-0.0.244-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2359f840c95364d779b86a822fe025fa416eb14adc661c1263bc39e90065f0bd"}, - {file = "ruff-0.0.244-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:8b85ced1e75b7cf1dd90d0708f8e46e2d58fc124334492cc5103f24d832a3922"}, - {file = "ruff-0.0.244-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:9c2d49c2021bf80f3e66968c1a41f89061911ffb7ed1f0d39a3204a45fc97ba7"}, - {file = "ruff-0.0.244-py3-none-musllinux_1_2_i686.whl", hash = "sha256:da77d573c7a5b27bad43468fb7e47e78e22715426beb4e673106d24a9a584838"}, - {file = "ruff-0.0.244-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:9f16fc3380753310af2a10e2867dfc133849e51c545561ec0a389aa93b3058b0"}, - {file = "ruff-0.0.244-py3-none-win32.whl", hash = "sha256:b3fc70a4c5d5a0ab8e5b3c3e818ca224913eee84f65bf63ee212af2bbd5f1792"}, - {file = "ruff-0.0.244-py3-none-win_amd64.whl", hash = "sha256:78bbc5d1cca0a8752f6e4b3f4485f4c4f2428543a0777d1bde865aa43bdab190"}, - {file = "ruff-0.0.244.tar.gz", hash = "sha256:7c05773e990348a6d7628b9b7294fe76303bc870dd94d9c34154bc1560053050"}, + {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:dd81b911d28925e7e8b323e8d06951554655021df8dd4ac3045d7212ac4ba080"}, + {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:dc586724a95b7d980aa17f671e173df00f0a2eef23f8babbeee663229a938fec"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c92db7101ef5bfc18e96777ed7bc7c822d545fa5977e90a585accac43d22f18a"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:13471684694d41ae0f1e8e3a7497e14cd57ccb7dd72ae08d56a159d6c9c3e30e"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a11567e20ea39d1f51aebd778685582d4c56ccb082c1161ffc10f79bebe6df35"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:00a818e2db63659570403e44383ab03c529c2b9678ba4ba6c105af7854008105"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:be60592f9d218b52f03384d1325efa9d3b41e4c4d55ea022cd548547cc42cd2b"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fbd2288890b88e8aab4499e55148805b58ec711053588cc2f0196a44f6e3d855"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3ef052283da7dec1987bba8d8733051c2325654641dfe5877a4022108098683"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:7022d66366d6fded4ba3889f73cd791c2d5621b2ccf34befc752cb0df70f5fad"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0a725823cb2a3f08ee743a534cb6935727d9e47409e4ad72c10a3faf042ad5ba"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:0034d5b6323e6e8fe91b2a1e55b02d92d0b582d2953a2b37a67a2d7dedbb7acc"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e5cb5526d69bb9143c2e4d2a115d08ffca3d8e0fddc84925a7b54931c96f5c02"}, + {file = "ruff-0.2.1-py3-none-win32.whl", hash = "sha256:6b95ac9ce49b4fb390634d46d6ece32ace3acdd52814671ccaf20b7f60adb232"}, + {file = "ruff-0.2.1-py3-none-win_amd64.whl", hash = "sha256:e3affdcbc2afb6f5bd0eb3130139ceedc5e3f28d206fe49f63073cb9e65988e0"}, + {file = "ruff-0.2.1-py3-none-win_arm64.whl", hash = "sha256:efababa8e12330aa94a53e90a81eb6e2d55f348bc2e71adbf17d9cad23c03ee6"}, + {file = "ruff-0.2.1.tar.gz", hash = "sha256:3b42b5d8677cd0c72b99fcaf068ffc62abb5a19e71b4a3b9cfa50658a0af02f1"}, ] [[package]] @@ -4037,38 +4006,40 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [[package]] name = "watchdog" -version = "3.0.0" +version = "4.0.0" description = "Filesystem events monitoring" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "watchdog-3.0.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:336adfc6f5cc4e037d52db31194f7581ff744b67382eb6021c868322e32eef41"}, - {file = "watchdog-3.0.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a70a8dcde91be523c35b2bf96196edc5730edb347e374c7de7cd20c43ed95397"}, - {file = "watchdog-3.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:adfdeab2da79ea2f76f87eb42a3ab1966a5313e5a69a0213a3cc06ef692b0e96"}, - {file = "watchdog-3.0.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:2b57a1e730af3156d13b7fdddfc23dea6487fceca29fc75c5a868beed29177ae"}, - {file = "watchdog-3.0.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7ade88d0d778b1b222adebcc0927428f883db07017618a5e684fd03b83342bd9"}, - {file = "watchdog-3.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7e447d172af52ad204d19982739aa2346245cc5ba6f579d16dac4bfec226d2e7"}, - {file = "watchdog-3.0.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:9fac43a7466eb73e64a9940ac9ed6369baa39b3bf221ae23493a9ec4d0022674"}, - {file = "watchdog-3.0.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:8ae9cda41fa114e28faf86cb137d751a17ffd0316d1c34ccf2235e8a84365c7f"}, - {file = "watchdog-3.0.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:25f70b4aa53bd743729c7475d7ec41093a580528b100e9a8c5b5efe8899592fc"}, - {file = "watchdog-3.0.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4f94069eb16657d2c6faada4624c39464f65c05606af50bb7902e036e3219be3"}, - {file = "watchdog-3.0.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:7c5f84b5194c24dd573fa6472685b2a27cc5a17fe5f7b6fd40345378ca6812e3"}, - {file = "watchdog-3.0.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3aa7f6a12e831ddfe78cdd4f8996af9cf334fd6346531b16cec61c3b3c0d8da0"}, - {file = "watchdog-3.0.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:233b5817932685d39a7896b1090353fc8efc1ef99c9c054e46c8002561252fb8"}, - {file = "watchdog-3.0.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:13bbbb462ee42ec3c5723e1205be8ced776f05b100e4737518c67c8325cf6100"}, - {file = "watchdog-3.0.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:8f3ceecd20d71067c7fd4c9e832d4e22584318983cabc013dbf3f70ea95de346"}, - {file = "watchdog-3.0.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:c9d8c8ec7efb887333cf71e328e39cffbf771d8f8f95d308ea4125bf5f90ba64"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:0e06ab8858a76e1219e68c7573dfeba9dd1c0219476c5a44d5333b01d7e1743a"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_armv7l.whl", hash = "sha256:d00e6be486affb5781468457b21a6cbe848c33ef43f9ea4a73b4882e5f188a44"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_i686.whl", hash = "sha256:c07253088265c363d1ddf4b3cdb808d59a0468ecd017770ed716991620b8f77a"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_ppc64.whl", hash = "sha256:5113334cf8cf0ac8cd45e1f8309a603291b614191c9add34d33075727a967709"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:51f90f73b4697bac9c9a78394c3acbbd331ccd3655c11be1a15ae6fe289a8c83"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:ba07e92756c97e3aca0912b5cbc4e5ad802f4557212788e72a72a47ff376950d"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:d429c2430c93b7903914e4db9a966c7f2b068dd2ebdd2fa9b9ce094c7d459f33"}, - {file = "watchdog-3.0.0-py3-none-win32.whl", hash = "sha256:3ed7c71a9dccfe838c2f0b6314ed0d9b22e77d268c67e015450a29036a81f60f"}, - {file = "watchdog-3.0.0-py3-none-win_amd64.whl", hash = "sha256:4c9956d27be0bb08fc5f30d9d0179a855436e655f046d288e2bcc11adfae893c"}, - {file = "watchdog-3.0.0-py3-none-win_ia64.whl", hash = "sha256:5d9f3a10e02d7371cd929b5d8f11e87d4bad890212ed3901f9b4d68767bee759"}, - {file = "watchdog-3.0.0.tar.gz", hash = "sha256:4d98a320595da7a7c5a18fc48cb633c2e73cda78f93cac2ef42d42bf609a33f9"}, + {file = "watchdog-4.0.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:39cb34b1f1afbf23e9562501673e7146777efe95da24fab5707b88f7fb11649b"}, + {file = "watchdog-4.0.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c522392acc5e962bcac3b22b9592493ffd06d1fc5d755954e6be9f4990de932b"}, + {file = "watchdog-4.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6c47bdd680009b11c9ac382163e05ca43baf4127954c5f6d0250e7d772d2b80c"}, + {file = "watchdog-4.0.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:8350d4055505412a426b6ad8c521bc7d367d1637a762c70fdd93a3a0d595990b"}, + {file = "watchdog-4.0.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c17d98799f32e3f55f181f19dd2021d762eb38fdd381b4a748b9f5a36738e935"}, + {file = "watchdog-4.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4986db5e8880b0e6b7cd52ba36255d4793bf5cdc95bd6264806c233173b1ec0b"}, + {file = "watchdog-4.0.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:11e12fafb13372e18ca1bbf12d50f593e7280646687463dd47730fd4f4d5d257"}, + {file = "watchdog-4.0.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:5369136a6474678e02426bd984466343924d1df8e2fd94a9b443cb7e3aa20d19"}, + {file = "watchdog-4.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:76ad8484379695f3fe46228962017a7e1337e9acadafed67eb20aabb175df98b"}, + {file = "watchdog-4.0.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:45cc09cc4c3b43fb10b59ef4d07318d9a3ecdbff03abd2e36e77b6dd9f9a5c85"}, + {file = "watchdog-4.0.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:eed82cdf79cd7f0232e2fdc1ad05b06a5e102a43e331f7d041e5f0e0a34a51c4"}, + {file = "watchdog-4.0.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ba30a896166f0fee83183cec913298151b73164160d965af2e93a20bbd2ab605"}, + {file = "watchdog-4.0.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:d18d7f18a47de6863cd480734613502904611730f8def45fc52a5d97503e5101"}, + {file = "watchdog-4.0.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2895bf0518361a9728773083908801a376743bcc37dfa252b801af8fd281b1ca"}, + {file = "watchdog-4.0.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:87e9df830022488e235dd601478c15ad73a0389628588ba0b028cb74eb72fed8"}, + {file = "watchdog-4.0.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:6e949a8a94186bced05b6508faa61b7adacc911115664ccb1923b9ad1f1ccf7b"}, + {file = "watchdog-4.0.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:6a4db54edea37d1058b08947c789a2354ee02972ed5d1e0dca9b0b820f4c7f92"}, + {file = "watchdog-4.0.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:d31481ccf4694a8416b681544c23bd271f5a123162ab603c7d7d2dd7dd901a07"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:8fec441f5adcf81dd240a5fe78e3d83767999771630b5ddfc5867827a34fa3d3"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_armv7l.whl", hash = "sha256:6a9c71a0b02985b4b0b6d14b875a6c86ddea2fdbebd0c9a720a806a8bbffc69f"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_i686.whl", hash = "sha256:557ba04c816d23ce98a06e70af6abaa0485f6d94994ec78a42b05d1c03dcbd50"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_ppc64.whl", hash = "sha256:d0f9bd1fd919134d459d8abf954f63886745f4660ef66480b9d753a7c9d40927"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:f9b2fdca47dc855516b2d66eef3c39f2672cbf7e7a42e7e67ad2cbfcd6ba107d"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:73c7a935e62033bd5e8f0da33a4dcb763da2361921a69a5a95aaf6c93aa03a87"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:6a80d5cae8c265842c7419c560b9961561556c4361b297b4c431903f8c33b269"}, + {file = "watchdog-4.0.0-py3-none-win32.whl", hash = "sha256:8f9a542c979df62098ae9c58b19e03ad3df1c9d8c6895d96c0d51da17b243b1c"}, + {file = "watchdog-4.0.0-py3-none-win_amd64.whl", hash = "sha256:f970663fa4f7e80401a7b0cbeec00fa801bf0287d93d48368fc3e6fa32716245"}, + {file = "watchdog-4.0.0-py3-none-win_ia64.whl", hash = "sha256:9a03e16e55465177d416699331b0f3564138f1807ecc5f2de9d55d8f188d08c7"}, + {file = "watchdog-4.0.0.tar.gz", hash = "sha256:e3e7065cbdabe6183ab82199d7a4f6b3ba0a438c5a512a68559846ccb76a78ec"}, ] [package.extras] @@ -4241,4 +4212,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.12" -content-hash = "acdfbbaa6a66455caeb71b0caa3582269c169efad6320d336e089a174bdb8083" +content-hash = "1bd87e4ee481292fa1c4ed69a41556d3e9d84210e925c034f9df055d42b8964d" diff --git a/pyproject.toml b/pyproject.toml index e9156670..aa7df935 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,12 +57,11 @@ fastparquet = "^2023.8.0" graspologic = "^3.3.0" [tool.poetry.group.dev.dependencies] -ruff = "^0.0.244" +ruff = "*" pre-commit = "^3.2.2" bumpversion = "*" coverage = "*" flake8 = "*" -flake8-docstrings = "^1.7.0" invoke = "*" isort = "*" pylint = "*" @@ -103,8 +102,24 @@ filterwarnings = ["ignore::DeprecationWarning",] [tool.ruff] -[tool.ruff.per-file-ignores] +[tool.ruff.lint] +select = [ + # pycodestyle + "E", + # pydocstyle + "D", +] +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] +ignore = ["E501","E402","E203","D213","D203"] + +[tool.ruff.lint.per-file-ignores] "pixelator/report/__init__.py" = ["E501"] +"**/tests/**" = ["D101", "D102", "D103", "D200", "D202", "D205", "D212" , "D400", "D401", "D403", "D404", "D415"] +# Since click uses a different layout for the docs strings to generate the +# cli docs, we ignore these rules here. +"src/pixelator/cli/**" = ["D200", "D212", "D400", "D415"] [tool.poetry-dynamic-versioning] enable = true From 481a63cecffe94711903325ae1a7f2e4133bfea2 Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Tue, 6 Feb 2024 16:44:58 +0100 Subject: [PATCH 02/13] Run ruff first since it is much faster --- .pre-commit-config.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea3e4a03..3b15ad49 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,13 @@ repos: hooks: - id: black + + - repo: https://github.com/charliermarsh/ruff-pre-commit + # Ruff version. + rev: "v0.2.1" + hooks: + - id: ruff + - repo: https://github.com/pycqa/flake8 rev: "6.0.0" # pick a git hash / tag to point to hooks: @@ -23,12 +30,6 @@ repos: - flake8-docstrings - pydoclint - - repo: https://github.com/charliermarsh/ruff-pre-commit - # Ruff version. - rev: "v0.2.1" - hooks: - - id: ruff - - repo: https://github.com/pre-commit/mirrors-mypy rev: "v1.3.0" # Use the sha / tag you want to point at hooks: From ffb828670dbb46703518df499502377803ab0df3 Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 14:42:30 +0100 Subject: [PATCH 03/13] WIP on fixing docs --- pyproject.toml | 1 + src/pixelator/__main__.py | 4 +- src/pixelator/amplicon/__init__.py | 3 +- .../analysis/colocalization/estimate.py | 24 ++++++- .../analysis/colocalization/permute.py | 9 +-- src/pixelator/annotate/aggregates.py | 9 +-- src/pixelator/annotate/cell_calling.py | 21 ++---- src/pixelator/annotate/constants.py | 3 +- src/pixelator/config/__init__.py | 3 +- src/pixelator/config/assay.py | 66 ++++++------------- src/pixelator/config/config_class.py | 33 +++------- src/pixelator/config/config_instance.py | 3 +- src/pixelator/config/plugin.py | 6 +- src/pixelator/config/utils.py | 6 +- src/pixelator/demux/__init__.py | 3 +- src/pixelator/demux/process.py | 6 +- src/pixelator/exception.py | 10 +-- src/pixelator/qc/__init__.py | 3 +- src/pixelator/qc/process.py | 9 +-- src/pixelator/report/workdir.py | 11 +--- src/pixelator/resources/__init__.py | 3 +- src/pixelator/test_utils/__init__.py | 3 +- src/pixelator/test_utils/adapterqc.py | 6 +- src/pixelator/test_utils/amplicon.py | 6 +- src/pixelator/test_utils/analysis.py | 6 +- src/pixelator/test_utils/base.py | 17 ++--- src/pixelator/test_utils/collapse.py | 6 +- src/pixelator/test_utils/config.py | 16 ++--- src/pixelator/test_utils/demux.py | 6 +- src/pixelator/test_utils/workflow.py | 10 +-- src/pixelator/test_utils/workflow_context.py | 12 ++-- tasks.py | 60 +++++------------ 32 files changed, 138 insertions(+), 246 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index aa7df935..3fca4916 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,6 +113,7 @@ select = [ fixable = ["ALL"] unfixable = [] ignore = ["E501","E402","E203","D213","D203"] +exclude = ["docs/conf.py"] [tool.ruff.lint.per-file-ignores] "pixelator/report/__init__.py" = ["E501"] diff --git a/src/pixelator/__main__.py b/src/pixelator/__main__.py index be86bf2c..a9a9e4c3 100644 --- a/src/pixelator/__main__.py +++ b/src/pixelator/__main__.py @@ -1,8 +1,8 @@ -""" -Top-level entrypoint for Pixelator +"""Top-level entrypoint for Pixelator. Copyright (c) 2022 Pixelgen Technologies AB. """ + import sys from pixelator.cli import main_cli diff --git a/src/pixelator/amplicon/__init__.py b/src/pixelator/amplicon/__init__.py index b25796f0..9185fbe1 100644 --- a/src/pixelator/amplicon/__init__.py +++ b/src/pixelator/amplicon/__init__.py @@ -1,4 +1,5 @@ -""" +"""Top-level module for amplicon. + Copyright (c) 2023 Pixelgen Technologies AB. """ diff --git a/src/pixelator/analysis/colocalization/estimate.py b/src/pixelator/analysis/colocalization/estimate.py index ad6a5d02..90880d81 100644 --- a/src/pixelator/analysis/colocalization/estimate.py +++ b/src/pixelator/analysis/colocalization/estimate.py @@ -1,4 +1,5 @@ -""" +"""Module for estimating colocalization statistics. + Copyright (c) 2023 Pixelgen Technologies AB. """ @@ -22,6 +23,15 @@ def estimate_observation_statistics( permutation_results: pd.DataFrame, funcs: Tuple[CoLocalizationFunction, ...], ): + """Estimates the observation statistics for colocalization analysis. + + :param observations: The observed data. + :param permutation_results: The permutation results. + :param funcs: Tuple of colocalization functions. + :return: The estimated observation statistics. + :rtype: pd.DataFrame + """ + def estimates(): for func in funcs: func_name = func.name @@ -61,6 +71,18 @@ def permutation_analysis_results( n=50, random_seed: Optional[int] = None, ) -> pd.DataFrame: + """Perform permutation analysis on colocalization data. + + :param data: The input data for colocalization analysis. + :param funcs: A tuple of colocalization functions to apply. + :param permuter: A function that generates permuted data for analysis. + :param transformer: A function to transform the permuted data before analysis. (optional) + :param n: The number of permutations to perform. Default is 50. + :param random_seed: The random seed for reproducibility. Default is None. + :return: The results of the permutation analysis. + :rtype: pd.DataFrame + """ + def constuct_permutation_data(data, n): for idx, permuted_df in enumerate(permuter(data, n=n, random_seed=random_seed)): df_for_comp = transformer(permuted_df) if transformer else permuted_df diff --git a/src/pixelator/analysis/colocalization/permute.py b/src/pixelator/analysis/colocalization/permute.py index d1bab432..ac608087 100644 --- a/src/pixelator/analysis/colocalization/permute.py +++ b/src/pixelator/analysis/colocalization/permute.py @@ -1,4 +1,5 @@ -""" +"""Module with functions for created permuted data. + Copyright (c) 2023 Pixelgen Technologies AB. """ @@ -25,8 +26,7 @@ def _get_random_number_generator( def permutations( df: RegionByCountsDataFrame, n=50, random_seed: Optional[int] = None ) -> Generator[RegionByCountsDataFrame, None, None]: - """ - Generate `n` permutatinos of the data provided in `df` + """Generate `n` permutatinos of the data provided in `df`. :param df: dataframe to use as basis of permutations :param n: number of permutations to generate, defaults to 50 @@ -43,7 +43,8 @@ def permute( df: RegionByCountsDataFrame, random_number_generator: Optional[RandomNumberGenerator] = None, ) -> RegionByCountsDataFrame: - """ + """Generate permutations of data frame. + Permute the given dataframe in a way that preserves the number of counts in each region. The proportions of each marker is kept approximately by sampling from a multinomial distribution of the diff --git a/src/pixelator/annotate/aggregates.py b/src/pixelator/annotate/aggregates.py index a86713a7..72baf305 100644 --- a/src/pixelator/annotate/aggregates.py +++ b/src/pixelator/annotate/aggregates.py @@ -1,5 +1,4 @@ -""" -This module contains functions for finding aggregates +"""This module contains functions for finding aggregates Copyright (c) 2022 Pixelgen Technologies AB. """ @@ -21,8 +20,7 @@ def specificity_tau(matrix: np.ndarray) -> np.ndarray: - """ - Tau specificity score computed as described in [1]_. + """Tau specificity score computed as described in [1]_. Essentially it gives us a score between 0 and 1, where a component that expresses a single marker would have a tau score of 1, and one where all @@ -48,8 +46,7 @@ def specificity_tau(matrix: np.ndarray) -> np.ndarray: def call_aggregates(adata: AnnData, inplace: bool = True) -> Optional[AnnData]: - """ - We defined aggregates as components where either: + """We defined aggregates as components where either: - A single or a handful of markers account for almost all of the count data. These can likely be attributed to single antibodies forming aggregates - Low tau scores, meaning a an even number of counts for multiple markers. diff --git a/src/pixelator/annotate/cell_calling.py b/src/pixelator/annotate/cell_calling.py index 6303d951..c47d98c3 100644 --- a/src/pixelator/annotate/cell_calling.py +++ b/src/pixelator/annotate/cell_calling.py @@ -1,5 +1,4 @@ -""" -This module contains functions for doing size-based cell calling +"""This module contains functions for doing size-based cell calling Copyright (c) 2022 Pixelgen Technologies AB. """ @@ -26,8 +25,7 @@ def find_component_size_limits( component_sizes: np.ndarray, direction: Literal["lower", "upper"], ) -> Optional[int]: - """ - This function will attempt to find a cutoff for a distribution of component sizes. + """This function will attempt to find a cutoff for a distribution of component sizes. The direction of the cut-off is determined by the `direction` parameter (lower for min size and upper for max size). @@ -66,8 +64,7 @@ def find_component_size_limits( """ def log_size_and_rank(df: pd.DataFrame) -> pd.DataFrame: - """ - Rank component sizes by size, sort by their rank, and compute the + """Rank component sizes by size, sort by their rank, and compute the log10 of both the sizes and ranks. The input dataframe must contain a `size` column with the component sizes. A new dataframe is returned with two new columns `log10_size` and `log10_rank`. @@ -79,8 +76,7 @@ def log_size_and_rank(df: pd.DataFrame) -> pd.DataFrame: return df def smooth(df: pd.DataFrame, x_var: str, y_var: str) -> pd.DataFrame: - """ - Calculate a smoothing spline of df[x_var] ~ df[y_var] + """Calculate a smoothing spline of df[x_var] ~ df[y_var] to make it possible to calculate a less unstable derivate. The input dataframe must contain the `x_var` and `y_var` columns, a new column `smooth` is added to the returned @@ -96,8 +92,7 @@ def smooth(df: pd.DataFrame, x_var: str, y_var: str) -> pd.DataFrame: return df def derivatives(df: pd.DataFrame, x_var: str) -> pd.DataFrame: - """ - Calculate the first and second derivatives of the smoothed + """Calculate the first and second derivatives of the smoothed `x_var` variable. The input dataframe must contain the `x_var` and `smooth` columns. The returned dataframe contains two new columns `der1` and `der2` with the @@ -108,8 +103,7 @@ def derivatives(df: pd.DataFrame, x_var: str) -> pd.DataFrame: return df def find_der1_vs_der2_outliers(df: pd.DataFrame) -> pd.Series: - """ - Find the distance from origo to each component in + """Find the distance from origo to each component in the space df[der1] ~ df[der2], then try to find outliers in the upper part of component ranks, by looking at the standard deviation of the distances. @@ -128,8 +122,7 @@ def find_der1_vs_der2_outliers(df: pd.DataFrame) -> pd.Series: return df["rank"] == rank - 1 def minimum_der2(df: pd.DataFrame) -> pd.Series: - """ - Find argmin element. The function returns + """Find argmin element. The function returns a boolean Series where the global minimum of `der2` evaluates to True. The input dataframe must contain the `der2` column. diff --git a/src/pixelator/annotate/constants.py b/src/pixelator/annotate/constants.py index 146229a8..0c039588 100644 --- a/src/pixelator/annotate/constants.py +++ b/src/pixelator/annotate/constants.py @@ -1,5 +1,4 @@ -""" -This module contains constants used as part of the annotation +"""This module contains constants used as part of the annotation modules. Copyright (c) 2022 Pixelgen Technologies AB. diff --git a/src/pixelator/config/__init__.py b/src/pixelator/config/__init__.py index 8fba1a3b..753f402b 100644 --- a/src/pixelator/config/__init__.py +++ b/src/pixelator/config/__init__.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ from pixelator.config.assay import ( diff --git a/src/pixelator/config/assay.py b/src/pixelator/config/assay.py index 1a337d84..c868a01f 100644 --- a/src/pixelator/config/assay.py +++ b/src/pixelator/config/assay.py @@ -1,5 +1,4 @@ -""" -This module contains classes and functions related to +"""This module contains classes and functions related to the different assay/designs used by pixelator. Copyright (c) 2022 Pixelgen Technologies AB. @@ -57,8 +56,7 @@ class RegionModel(BaseModel): @validator("sequence") def check_valid_dna_string(cls, v: str, values: Mapping[str, Any]) -> str: - """ - Validate DNA strings. + """Validate DNA strings. :param v: DNA string to validate :param values: Pydantic fields @@ -73,8 +71,7 @@ def check_valid_dna_string(cls, v: str, values: Mapping[str, Any]) -> str: class AssayModel(BaseModel): - """ - Validation model for assay configuration. + """Validation model for assay configuration. :ivar name: Name of the assay :ivar assay_spec: List of assay regions @@ -86,8 +83,7 @@ class AssayModel(BaseModel): class Region: - """ - Class representing a region in an assay. + """Class representing a region in an assay. :ivar region_id: unique ID of the region :ivar region_type: type of the region @@ -144,8 +140,7 @@ def __init__( self.sequence = self.get_sequence() def set_parent_id(self, parent_id): - """ - Set the parent id of this region. + """Set the parent id of this region. :param parent_id: parent id to set :param recursive: if True, set the parent id of all sub-regions @@ -153,9 +148,7 @@ def set_parent_id(self, parent_id): self.parent_id = parent_id def get_sequence(self) -> str: - """ - Return the sequence representation of this region. - """ + """Return the sequence representation of this region.""" s = "" if self.regions: for r in self.regions: @@ -168,9 +161,7 @@ def get_sequence(self) -> str: return s def get_len(self) -> Tuple[int, int]: - """ - Return the minimum and maximum length of this region. - """ + """Return the minimum and maximum length of this region.""" min_l, max_l = 0, 0 if self.regions: for r in self.regions: @@ -223,9 +214,7 @@ def to_dict(self): return d def get_region_by_id(self, region_id: str) -> Optional["Region"]: - """ - Lookup a region by the region_id field. - """ + """Lookup a region by the region_id field.""" if self.region_id == region_id: return self @@ -237,9 +226,7 @@ def get_region_by_id(self, region_id: str) -> Optional["Region"]: return None def get_regions_by_type(self, region_type: str) -> List["Region"]: - """ - Return all regions with specified region_type - """ + """Return all regions with specified region_type""" found = [] if self.region_type == region_type: @@ -252,9 +239,7 @@ def get_regions_by_type(self, region_type: str) -> List["Region"]: return found def get_leaves(self) -> List["Region"]: - """ - Return a depth-first list of all leaf regions - """ + """Return a depth-first list of all leaf regions""" leaves = [] if not self.regions: @@ -266,9 +251,7 @@ def get_leaves(self) -> List["Region"]: return leaves def get_leaf_region_types(self) -> Set[RegionType]: - """ - Return a set of all leaf region types - """ + """Return a set of all leaf region types""" leaves = self.get_leaves() rtypes = set() @@ -278,9 +261,7 @@ def get_leaf_region_types(self) -> Set[RegionType]: return rtypes def get_subregion_ids(self) -> Set[str]: - """ - Return a set of the region_ids of all subregions - """ + """Return a set of the region_ids of all subregions""" ids: Set[str] = set() if not self.regions: @@ -294,8 +275,7 @@ def get_subregion_ids(self) -> Set[str]: class Assay: - """ - Class representing a specific assay design. + """Class representing a specific assay design. An assay contains metadata and a list of (possible nested regions) defining the structure of the assay reads. @@ -370,9 +350,7 @@ def _update_parent_ids(self) -> None: @property def region_ids(self) -> Set[str]: - """ - Return a set with all regions ids in this assay. - """ + """Return a set with all regions ids in this assay.""" ids = set() for r in self.assay_spec: ids.add(r.region_id) @@ -382,8 +360,7 @@ def region_ids(self) -> Set[str]: @classmethod def from_yaml(cls, filename: PathType) -> "Assay": - """ - Parse an assay from a yaml file. + """Parse an assay from a yaml file. :param filename: path to a design config file """ @@ -395,9 +372,7 @@ def to_json(self): return json.dumps(self, default=lambda o: o.__dict__, sort_keys=False, indent=4) def get_sequence(self) -> str: - """ - Return a sequence representing this region. - """ + """Return a sequence representing this region.""" s = [] for region in self.assay_spec: s.append(region.get_sequence()) @@ -409,8 +384,7 @@ def update_spec(self): r.update_attr() def get_region_by_id(self, region_id: str) -> Optional[Region]: - """ - Retrieve a region by its id. + """Retrieve a region by its id. :param region_id: id of the region to retrieve :return: region with the given id or None if not found @@ -424,8 +398,7 @@ def get_region_by_id(self, region_id: str) -> Optional[Region]: @cache def get_regions_by_type(self, region_type: RegionType) -> List[Region]: - """ - Retrieve all regions of a given type. + """Retrieve all regions of a given type. :param region_type: region type to retrieve :return: list of regions with the given type @@ -442,8 +415,7 @@ def __len__(self) -> int: def get_position_in_parent(assay: Assay, region_id: str) -> Tuple[int, int]: - """ - Return the start and end position of a region relative to its parent region. + """Return the start and end position of a region relative to its parent region. This assumes the amplicon consists of only fixed length regions in the path from the start of the amplicon up until the region of interest. diff --git a/src/pixelator/config/config_class.py b/src/pixelator/config/config_class.py index 5473ab47..31c7da36 100644 --- a/src/pixelator/config/config_class.py +++ b/src/pixelator/config/config_class.py @@ -1,5 +1,4 @@ -""" -This module contains classes and functions related to +"""This module contains classes and functions related to the configuration file for pixelator (assay settings). Copyright (c) 2022 Pixelgen Technologies AB. @@ -27,9 +26,7 @@ class Config: - """ - Class containing the pixelator configuration (assay settings) - """ + """Class containing the pixelator configuration (assay settings)""" def __init__( self, @@ -48,9 +45,7 @@ def __init__( self.panels[key].append(p) def load_assay(self, path: PathType) -> None: - """ - Load an assay from a yaml file. - """ + """Load an assay from a yaml file.""" assay = Assay.from_yaml(path) self.assays[assay.name] = assay @@ -60,9 +55,7 @@ def load_panel_file(self, path: PathType) -> None: self.panels[key].append(panel) def load_assays(self, path: PathType): - """ - Load all assays from a directory containing yaml files. - """ + """Load all assays from a directory containing yaml files.""" search_path = Path(path) yaml_files = list( @@ -76,9 +69,7 @@ def load_assays(self, path: PathType): self.load_assay(f) def load_panels(self, path: PathType): - """ - Load all panel files from a directory containing csv files. - """ + """Load all panel files from a directory containing csv files.""" search_path = Path(path) csv_files = list(search_path.glob("*.csv")) @@ -87,17 +78,13 @@ def load_panels(self, path: PathType): self.load_panel_file(f) def get_assay(self, assay_name: str) -> Optional[Assay]: - """ - Get an assay by name. - """ + """Get an assay by name.""" return self.assays.get(assay_name) def get_panel( self, panel_name: str, version: Optional[str] = None ) -> Optional[AntibodyPanel]: - """ - Get a panel by name. - """ + """Get a panel by name.""" panels_with_key = self.panels.get(panel_name) if panels_with_key is None: return None @@ -121,8 +108,7 @@ def keyfunc(p): def load_assays_package(config: Config, package_name: str) -> Config: - """ - Load default assays from a resources package. + """Load default assays from a resources package. :param config: The config object to load assays into :param package_name: The name of the package to load assays from @@ -138,8 +124,7 @@ def load_assays_package(config: Config, package_name: str) -> Config: def load_panels_package(config: Config, package_name: str) -> Config: - """ - Load default panels from a resources package. + """Load default panels from a resources package. :param config: The config object to load panel files into :param package_name: The name of the package to load panels from diff --git a/src/pixelator/config/config_instance.py b/src/pixelator/config/config_instance.py index f7fc86cd..9e9ad1a6 100644 --- a/src/pixelator/config/config_instance.py +++ b/src/pixelator/config/config_instance.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ from pixelator.config.config_class import ( diff --git a/src/pixelator/config/plugin.py b/src/pixelator/config/plugin.py index 178db27e..72e4d906 100644 --- a/src/pixelator/config/plugin.py +++ b/src/pixelator/config/plugin.py @@ -1,5 +1,4 @@ -""" -Helpers for configuration plugin entrypoints +"""Helpers for configuration plugin entrypoints Copyright (c) 2023 Pixelgen Technologies AB. """ @@ -23,8 +22,7 @@ def fetch_config_plugins() -> Generator[importlib.metadata.EntryPoint, None, None]: - """ - Find plugins and return them as in a generator + """Find plugins and return them as in a generator :returns: A generator of the loaded plugins """ diff --git a/src/pixelator/config/utils.py b/src/pixelator/config/utils.py index c18ec29a..a03ce0ce 100644 --- a/src/pixelator/config/utils.py +++ b/src/pixelator/config/utils.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ from pathlib import Path @@ -11,8 +10,7 @@ def load_yaml_file(path: PathType) -> Any: - """ - Load an arbitrary yaml file. + """Load an arbitrary yaml file. :param path: path to the yaml file :raises FileExistsError: If the path does not exist diff --git a/src/pixelator/demux/__init__.py b/src/pixelator/demux/__init__.py index 96b4236d..6d5e1d4d 100644 --- a/src/pixelator/demux/__init__.py +++ b/src/pixelator/demux/__init__.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ from pixelator.demux.process import demux_fastq diff --git a/src/pixelator/demux/process.py b/src/pixelator/demux/process.py index c71e5190..414514c9 100644 --- a/src/pixelator/demux/process.py +++ b/src/pixelator/demux/process.py @@ -1,5 +1,4 @@ -""" -This module contains functions for demultiplex reads belonging to antibody panels +"""This module contains functions for demultiplex reads belonging to antibody panels Copyright (c) 2022 Pixelgen Technologies AB. """ @@ -30,8 +29,7 @@ def demux_fastq( cores: int, verbose: bool, ) -> None: - """ - This function is a wrapper around `cutadapt` to process a `fastq` + """This function is a wrapper around `cutadapt` to process a `fastq` file with molecular pixelation data. A `fasta` file with the barcodes to use to demultiplex must be provided (antibody name and its sequence). The fastq will be processed to demultiplex its barcode with the ones diff --git a/src/pixelator/exception.py b/src/pixelator/exception.py index 1649c95b..528600d8 100644 --- a/src/pixelator/exception.py +++ b/src/pixelator/exception.py @@ -1,5 +1,4 @@ -""" -This module contains all the extra exception classes and handling +"""This module contains all the extra exception classes and handling defined by pixelator Copyright (c) 2022 Pixelgen Technologies AB. @@ -10,13 +9,14 @@ class FileFqGzEmpty(Exception): - """ - Class to manage empty fastq.gz file exceptions. + """Class to manage empty fastq.gz file exceptions. - Attributes: + Attributes + ---------- msg: the error message to output fname: the name of the file size: the size of the file uncompressed (should be 0) + """ def __init__(self, msg: str, fname: Union[str, Path], size: int): diff --git a/src/pixelator/qc/__init__.py b/src/pixelator/qc/__init__.py index a892d3a8..2b341f1c 100644 --- a/src/pixelator/qc/__init__.py +++ b/src/pixelator/qc/__init__.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ from pixelator.qc.process import adapter_qc_fastq, qc_fastq diff --git a/src/pixelator/qc/process.py b/src/pixelator/qc/process.py index e7c2ddf7..03161864 100644 --- a/src/pixelator/qc/process.py +++ b/src/pixelator/qc/process.py @@ -1,5 +1,4 @@ -""" -This module contains functions for processing and QC any MPX amplicon design +"""This module contains functions for processing and QC any MPX amplicon design Copyright (c) 2022 Pixelgen Technologies AB. """ @@ -33,8 +32,7 @@ def qc_fastq( remove_polyg: bool, verbose: bool, ) -> None: - """ - This function is a wrapper around `fastp` to pre-process a `fastq` + """This function is a wrapper around `fastp` to pre-process a `fastq` file. Duplicated sequences are removed, polyG sequences of length >= 5 are trimmed. Some filters are used to discard reads (maximum and minimum read length and the maximum number of Ns in a read). @@ -148,8 +146,7 @@ def adapter_qc_fastq( cores: int, verbose: bool, ) -> None: - """ - This function is a wrapper around `cutadapt` to process a `fastq` + """This function is a wrapper around `cutadapt` to process a `fastq` file with molecular pixelation data. The provided PBS1/2 sequences will be searched in the reads and only the reads that contain both sequences will be kept. diff --git a/src/pixelator/report/workdir.py b/src/pixelator/report/workdir.py index 79160197..968c133f 100644 --- a/src/pixelator/report/workdir.py +++ b/src/pixelator/report/workdir.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ import itertools import logging @@ -12,9 +11,7 @@ class PixelatorWorkdir: - """ - Tools to collect files from the workdir folder. - """ + """Tools to collect files from the workdir folder.""" _SEARCH_PATTERNS = { "metadata": "**/*.meta.json", @@ -53,8 +50,7 @@ def _collect_files( return grouped_files def _collect_metadata_files(self) -> Dict[str, List[Path]]: - """ - Collect all metadata files. + """Collect all metadata files. Metadata files are those that end with `.meta.json`. The files will be returned as a flat list @@ -62,7 +58,6 @@ def _collect_metadata_files(self) -> Dict[str, List[Path]]: :raises AssertionError: If no metadata files are found :return: A list of metadata files """ - files = self._collect_files("metadata") if files is None or len(files) == 0: logging.warning(f"No metadata files found in {self.basedir}") diff --git a/src/pixelator/resources/__init__.py b/src/pixelator/resources/__init__.py index 7b547232..900f523a 100644 --- a/src/pixelator/resources/__init__.py +++ b/src/pixelator/resources/__init__.py @@ -1,3 +1,2 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ diff --git a/src/pixelator/test_utils/__init__.py b/src/pixelator/test_utils/__init__.py index 7deef7ce..ca8f4223 100644 --- a/src/pixelator/test_utils/__init__.py +++ b/src/pixelator/test_utils/__init__.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ from .adapterqc import BaseAdapterQCTestsMixin from .amplicon import BaseAmpliconTestsMixin diff --git a/src/pixelator/test_utils/adapterqc.py b/src/pixelator/test_utils/adapterqc.py index df95f01b..f54379dc 100644 --- a/src/pixelator/test_utils/adapterqc.py +++ b/src/pixelator/test_utils/adapterqc.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ import logging @@ -11,8 +10,7 @@ class BaseAdapterQCTestsMixin(BaseWorkflowTestMixin): - """ - Base class for adapterqc tests. + """Base class for adapterqc tests. Test cases (defined in this class or in subclasses) that depend on the output should be marked with: diff --git a/src/pixelator/test_utils/amplicon.py b/src/pixelator/test_utils/amplicon.py index bea5ca62..9555a7c0 100644 --- a/src/pixelator/test_utils/amplicon.py +++ b/src/pixelator/test_utils/amplicon.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ import logging from pathlib import Path @@ -12,8 +11,7 @@ class BaseAmpliconTestsMixin(BaseWorkflowTestMixin): - """ - Base class for amplicon command tests. + """Base class for amplicon command tests. Test cases (defined in this class or in subclasses) that depend on the output should be marked with: diff --git a/src/pixelator/test_utils/analysis.py b/src/pixelator/test_utils/analysis.py index cdfa09f6..b8ad2b33 100644 --- a/src/pixelator/test_utils/analysis.py +++ b/src/pixelator/test_utils/analysis.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ import logging @@ -11,8 +10,7 @@ class BaseAnalysisTestsMixin(BaseWorkflowTestMixin): - """ - Base class for analysis command tests. + """Base class for analysis command tests. Test cases (defined in this class or in subclasses) that depend on the output should be marked with: diff --git a/src/pixelator/test_utils/base.py b/src/pixelator/test_utils/base.py index 258df940..ca0eccc0 100644 --- a/src/pixelator/test_utils/base.py +++ b/src/pixelator/test_utils/base.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ from typing import Any, ClassVar, List @@ -7,8 +6,7 @@ class BaseWorkflowTestMixin: - """ - Base class for WorkflowTestMixin classes. + """Base class for WorkflowTestMixin classes. These mixin classes are always used in conjunction with the PixlatorWorkflowTest. """ @@ -17,8 +15,7 @@ class BaseWorkflowTestMixin: # Type hints for these methods that are injected through __init_subclass__. def __get_data(self, key: str) -> Any: - """ - Try to retrieve a key from various data sources. + """Try to retrieve a key from various data sources. Following sources are tried in order: @@ -56,9 +53,7 @@ def __this_logs(self) -> str: # type: ignore ... def __init_subclass__(cls, **kwargs): - """ - Some hackery to bind data access functions. - """ + """Some hackery to bind data access functions.""" super().__init_subclass__(**kwargs) thisclass = BaseWorkflowTestMixin clsname = cls.__name__ @@ -102,9 +97,7 @@ def __base_get_data(self, name: str, *, data_key=None) -> Any: return getattr(self, name, None) def __base_get_options(self, key: str): - """ - Retrieve test config data from the class variables defined in the test class. - """ + """Retrieve test config data from the class variables defined in the test class.""" if not hasattr(self, "options"): raise ValueError("No options section found in test config.") diff --git a/src/pixelator/test_utils/collapse.py b/src/pixelator/test_utils/collapse.py index e56a2d33..5af2e742 100644 --- a/src/pixelator/test_utils/collapse.py +++ b/src/pixelator/test_utils/collapse.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ import logging from pathlib import Path @@ -12,8 +11,7 @@ class BaseCollapseTestsMixin(BaseWorkflowTestMixin): - """ - Base class for collapse command tests. + """Base class for collapse command tests. Test cases (defined in this class or in subclasses) that depend on the output should be marked with: diff --git a/src/pixelator/test_utils/config.py b/src/pixelator/test_utils/config.py index 4ad90d51..9fa77a0d 100644 --- a/src/pixelator/test_utils/config.py +++ b/src/pixelator/test_utils/config.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ from pathlib import Path from typing import Any, Dict @@ -10,9 +9,7 @@ class WorkflowConfig: - """ - Class used to load and query the workflow tests configuration file. - """ + """Class used to load and query the workflow tests configuration file.""" def __init__(self, config_file: PathType): self.config_file = config_file @@ -21,8 +18,7 @@ def __init__(self, config_file: PathType): self._validate() def get_test_config(self, test_name: str) -> Any: - """ - Retrieve config data for a specific test case. + """Retrieve config data for a specific test case. Currently only "small", "single-cell" and "tissue" are implemented. You can use arbitrary names for your own tests, and then link your @@ -39,8 +35,7 @@ def keys(self): @classmethod def _parse(cls, config_file: PathType) -> Dict[str, Any]: - """ - Load and resolve relative paths in the config file. + """Load and resolve relative paths in the config file. :param config_file: path to the config file :returns: the config object parsed from the `config_file` @@ -54,8 +49,7 @@ def _parse(cls, config_file: PathType) -> Dict[str, Any]: @classmethod def _resolve_relative_paths(cls, config_file: Path, config: Dict[str, Any]): - """ - Resolve relative paths in the config file. + """Resolve relative paths in the config file. All relative paths in the config file are resolved relative to the parent directory of the config file. diff --git a/src/pixelator/test_utils/demux.py b/src/pixelator/test_utils/demux.py index a9da2838..0716464a 100644 --- a/src/pixelator/test_utils/demux.py +++ b/src/pixelator/test_utils/demux.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ import logging from pathlib import Path @@ -14,8 +13,7 @@ class BaseDemuxTestsMixin(BaseWorkflowTestMixin): - """ - Base class for demux command tests. + """Base class for demux command tests. Test cases (defined in this class or in subclasses) that depend on the output should be marked with: diff --git a/src/pixelator/test_utils/workflow.py b/src/pixelator/test_utils/workflow.py index df041a34..640a8da4 100644 --- a/src/pixelator/test_utils/workflow.py +++ b/src/pixelator/test_utils/workflow.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ from pathlib import Path @@ -32,8 +31,7 @@ class PixelatorWorkflowTest( BasePreQCTestsMixin, BaseAmpliconTestsMixin, ): - """ - Pixelator workflow test base class. + """Pixelator workflow test base class. This class bundles all the basic tests for each command in the pixelator workflow. It is intended to be used as a base class for new workflow tests. @@ -66,7 +64,5 @@ def test_some_annotate_output(self): @property def workdir(self) -> Path: - """ - Return the workdir from the workflow context. - """ + """Return the workdir from the workflow context.""" return self.context.workdir diff --git a/src/pixelator/test_utils/workflow_context.py b/src/pixelator/test_utils/workflow_context.py index 2f2399b8..77062b89 100644 --- a/src/pixelator/test_utils/workflow_context.py +++ b/src/pixelator/test_utils/workflow_context.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2023 Pixelgen Technologies AB. +"""Copyright (c) 2023 Pixelgen Technologies AB. """ import logging import shutil @@ -16,8 +15,7 @@ class PixelatorWorkflowContext: - """ - Helper class for workflow tests. + """Helper class for workflow tests. This class is used to run the pixelator CLI and store the results. It also provides access to the test configuration in yaml or as class variables @@ -77,8 +75,7 @@ def run_command( return result def _link_files(self, files: List[str], suffix: str = ""): - """ - Symlink test files into the temporary working directory. + """Symlink test files into the temporary working directory. If no suffix is given files will be linked directly into the working directory. @@ -105,8 +102,7 @@ def _link_files(self, files: List[str], suffix: str = ""): @pytest.fixture(scope="class") def use_workflow_context(request, tmp_path_factory): - """ - Fixture to set up a working directory and WorkflowContext helper. + """Fixture to set up a working directory and WorkflowContext helper. This fixture is class scoped so that the working directory is reused across individual pixelator commands in a single BasePixelatorWorkflow subclass. diff --git a/tasks.py b/tasks.py index 9f47ccea..4b9eb588 100644 --- a/tasks.py +++ b/tasks.py @@ -1,10 +1,10 @@ -""" -Tasks for maintaining the project. +"""Tasks for maintaining the project. Execute 'invoke --list' for guidance on using Invoke Copyright (c) 2022 Pixelgen Technologies AB. """ + import platform import shutil import sys @@ -44,9 +44,7 @@ def _run(c, command, **kwargs): @task(help={"check": "Checks if source is formatted without applying changes"}) def format(c, check=False): - """ - Format code - """ + """Format code.""" python_dirs_string = " ".join(PYTHON_DIRS) # Run black black_options = "--diff --color --check" if check else "" @@ -55,9 +53,7 @@ def format(c, check=False): @task def typecheck(c): - """ - Run type checking on all python variables - """ + """Run type checking on all python variables.""" _run( c, f"mypy --ignore-missing-imports --install-types --non-interactive {SOURCE_DIR}", @@ -66,9 +62,7 @@ def typecheck(c): @task def lint(c): - """ - Run all linting - """ + """Run all linting.""" flake8_result = c.run( "flake8 --ignore=E501,E402,W503,E203 {}".format(" ".join(PYTHON_DIRS)), warn=True, @@ -85,9 +79,7 @@ def lint(c): optional=["basetemp"], help={"basetemp": "The base temp directory for test output"} ) def test(c, basetemp=None): - """ - Run tests - """ + """Run tests.""" cmd = "" if basetemp is None: cmd = "python -m pytest -s" @@ -105,9 +97,7 @@ def test(c, basetemp=None): }, ) def test_small_workflow(c, test_case=None, basetemp=None): - """ - Run tests - """ + """Run tests.""" cmd = "pytest -s " if basetemp: cmd += f' --basetemp="{str(basetemp)}" ' @@ -120,9 +110,7 @@ def test_small_workflow(c, test_case=None, basetemp=None): @task(help={"publish": "Publish the result via coveralls"}) def coverage(c, publish=False): - """ - Create coverage report - """ + """Create coverage report.""" _run(c, "coverage run --source {} -m pytest".format(SOURCE_DIR)) _run(c, "coverage report") if publish: @@ -136,9 +124,7 @@ def coverage(c, publish=False): @task(help={"launch": "Launch documentation in the web browser"}) def docs(c, launch=True): - """ - Generate documentation - """ + """Generate documentation.""" _run(c, "sphinx-build -b html {} {}".format(DOCS_DIR, DOCS_BUILD_DIR)) if launch: webbrowser.open(DOCS_INDEX.as_uri()) @@ -146,17 +132,13 @@ def docs(c, launch=True): @task def clean_docs(c): - """ - Clean up files from documentation builds - """ + """Clean up files from documentation builds.""" _run(c, "rm -fr {}".format(DOCS_BUILD_DIR)) @task def clean_build(c): - """ - Clean up files from package building - """ + """Clean up files from package building.""" _run(c, "rm -fr build/") _run(c, "rm -fr dist/") _run(c, "rm -fr .eggs/") @@ -166,9 +148,7 @@ def clean_build(c): @task def clean_python(c): - """ - Clean up python file artifacts - """ + """Clean up python file artifacts.""" _run(c, "find . -name '*.pyc' -exec rm -f {} +") _run(c, "find . -name '*.pyo' -exec rm -f {} +") _run(c, "find . -name '*~' -exec rm -f {} +") @@ -177,9 +157,7 @@ def clean_python(c): @task def clean_tests(c): - """ - Clean up files from testing - """ + """Clean up files from testing.""" _delete_file(COVERAGE_FILE) shutil.rmtree(TOX_DIR, ignore_errors=True) shutil.rmtree(COVERAGE_DIR, ignore_errors=True) @@ -187,23 +165,17 @@ def clean_tests(c): @task(pre=[clean_build, clean_python, clean_tests, clean_docs]) def clean(c): - """ - Runs all clean sub-tasks - """ + """Runs all clean sub-tasks.""" pass @task(clean) def dist(c): - """ - Build source and wheel packages - """ + """Build source and wheel packages.""" _run(c, "poetry build") @task(pre=[clean, dist]) def release(c): - """ - Make a release of the python package to pypi - """ + """Make a release of the python package to pypi.""" _run(c, "poetry publish") From 7921ca000dee88f6a1fd68d632635355916c1c3d Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 15:37:21 +0100 Subject: [PATCH 04/13] WIP on fixing up docs --- src/pixelator/annotate/aggregates.py | 2 +- src/pixelator/config/assay.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pixelator/annotate/aggregates.py b/src/pixelator/annotate/aggregates.py index 72baf305..5230f5a5 100644 --- a/src/pixelator/annotate/aggregates.py +++ b/src/pixelator/annotate/aggregates.py @@ -1,4 +1,4 @@ -"""This module contains functions for finding aggregates +"""This module contains functions for finding aggregates. Copyright (c) 2022 Pixelgen Technologies AB. """ diff --git a/src/pixelator/config/assay.py b/src/pixelator/config/assay.py index c868a01f..a1fe9eee 100644 --- a/src/pixelator/config/assay.py +++ b/src/pixelator/config/assay.py @@ -1,8 +1,8 @@ -"""This module contains classes and functions related to -the different assay/designs used by pixelator. +"""Module containing classes and functions related to the different assay/designs used by pixelator. Copyright (c) 2022 Pixelgen Technologies AB. """ + import enum import json from typing import Any, List, Mapping, Optional, Set, Tuple @@ -15,7 +15,7 @@ class RegionType(str, enum.Enum): - """Enum class representing different sequence types""" + """Enum class representing different sequence types.""" UMI = "umi" UPI = "upi" @@ -44,6 +44,8 @@ class SequenceType(str, enum.Enum): class RegionModel(BaseModel): + """Validation model for region configuration.""" + region_id: str region_type: RegionType name: str @@ -108,6 +110,7 @@ def __init__( regions: Optional[List["Region"]] = None, data: Optional[Mapping[str, Any]] = None, ) -> None: + """Initialize a Region.""" self.parent_id = None self.region_id = region_id self.region_type = region_type From ada108636aef17ee71646e0c8146bdfd5fdde0cd Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 15:41:05 +0100 Subject: [PATCH 05/13] Adding periods to end of summary lines --- src/pixelator/annotate/cell_calling.py | 2 +- src/pixelator/config/assay.py | 8 ++++---- src/pixelator/config/config_class.py | 2 +- src/pixelator/config/plugin.py | 4 ++-- src/pixelator/demux/process.py | 2 +- src/pixelator/exception.py | 2 +- src/pixelator/qc/process.py | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pixelator/annotate/cell_calling.py b/src/pixelator/annotate/cell_calling.py index c47d98c3..6712295f 100644 --- a/src/pixelator/annotate/cell_calling.py +++ b/src/pixelator/annotate/cell_calling.py @@ -1,4 +1,4 @@ -"""This module contains functions for doing size-based cell calling +"""This module contains functions for doing size-based cell calling. Copyright (c) 2022 Pixelgen Technologies AB. """ diff --git a/src/pixelator/config/assay.py b/src/pixelator/config/assay.py index a1fe9eee..f19098f4 100644 --- a/src/pixelator/config/assay.py +++ b/src/pixelator/config/assay.py @@ -229,7 +229,7 @@ def get_region_by_id(self, region_id: str) -> Optional["Region"]: return None def get_regions_by_type(self, region_type: str) -> List["Region"]: - """Return all regions with specified region_type""" + """Return all regions with specified region_type.""" found = [] if self.region_type == region_type: @@ -242,7 +242,7 @@ def get_regions_by_type(self, region_type: str) -> List["Region"]: return found def get_leaves(self) -> List["Region"]: - """Return a depth-first list of all leaf regions""" + """Return a depth-first list of all leaf regions.""" leaves = [] if not self.regions: @@ -254,7 +254,7 @@ def get_leaves(self) -> List["Region"]: return leaves def get_leaf_region_types(self) -> Set[RegionType]: - """Return a set of all leaf region types""" + """Return a set of all leaf region types.""" leaves = self.get_leaves() rtypes = set() @@ -264,7 +264,7 @@ def get_leaf_region_types(self) -> Set[RegionType]: return rtypes def get_subregion_ids(self) -> Set[str]: - """Return a set of the region_ids of all subregions""" + """Return a set of the region_ids of all subregions.""" ids: Set[str] = set() if not self.regions: diff --git a/src/pixelator/config/config_class.py b/src/pixelator/config/config_class.py index 31c7da36..888d193f 100644 --- a/src/pixelator/config/config_class.py +++ b/src/pixelator/config/config_class.py @@ -26,7 +26,7 @@ class Config: - """Class containing the pixelator configuration (assay settings)""" + """Class containing the pixelator configuration (assay settings).""" def __init__( self, diff --git a/src/pixelator/config/plugin.py b/src/pixelator/config/plugin.py index 72e4d906..6a8503ca 100644 --- a/src/pixelator/config/plugin.py +++ b/src/pixelator/config/plugin.py @@ -1,4 +1,4 @@ -"""Helpers for configuration plugin entrypoints +"""Helpers for configuration plugin entrypoints. Copyright (c) 2023 Pixelgen Technologies AB. """ @@ -22,7 +22,7 @@ def fetch_config_plugins() -> Generator[importlib.metadata.EntryPoint, None, None]: - """Find plugins and return them as in a generator + """Find plugins and return them as in a generator. :returns: A generator of the loaded plugins """ diff --git a/src/pixelator/demux/process.py b/src/pixelator/demux/process.py index 414514c9..e88ed351 100644 --- a/src/pixelator/demux/process.py +++ b/src/pixelator/demux/process.py @@ -1,4 +1,4 @@ -"""This module contains functions for demultiplex reads belonging to antibody panels +"""This module contains functions for demultiplex reads belonging to antibody panels. Copyright (c) 2022 Pixelgen Technologies AB. """ diff --git a/src/pixelator/exception.py b/src/pixelator/exception.py index 528600d8..17f89119 100644 --- a/src/pixelator/exception.py +++ b/src/pixelator/exception.py @@ -1,5 +1,5 @@ """This module contains all the extra exception classes and handling -defined by pixelator +defined by pixelator. Copyright (c) 2022 Pixelgen Technologies AB. """ diff --git a/src/pixelator/qc/process.py b/src/pixelator/qc/process.py index 03161864..4d636f8c 100644 --- a/src/pixelator/qc/process.py +++ b/src/pixelator/qc/process.py @@ -1,4 +1,4 @@ -"""This module contains functions for processing and QC any MPX amplicon design +"""This module contains functions for processing and QC any MPX amplicon design. Copyright (c) 2022 Pixelgen Technologies AB. """ From 9c2e8d507b3f9a401d6056e521aab6d02215ca5b Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 15:42:25 +0100 Subject: [PATCH 06/13] Set short summaries on one line --- src/pixelator/config/__init__.py | 3 +-- src/pixelator/config/config_instance.py | 3 +-- src/pixelator/config/utils.py | 3 +-- src/pixelator/demux/__init__.py | 3 +-- src/pixelator/qc/__init__.py | 3 +-- src/pixelator/report/workdir.py | 3 +-- src/pixelator/resources/__init__.py | 3 +-- src/pixelator/test_utils/__init__.py | 3 +-- src/pixelator/test_utils/adapterqc.py | 3 +-- src/pixelator/test_utils/amplicon.py | 3 +-- src/pixelator/test_utils/analysis.py | 3 +-- src/pixelator/test_utils/base.py | 3 +-- src/pixelator/test_utils/collapse.py | 3 +-- src/pixelator/test_utils/config.py | 3 +-- src/pixelator/test_utils/demux.py | 3 +-- src/pixelator/test_utils/workflow.py | 3 +-- src/pixelator/test_utils/workflow_context.py | 3 +-- 17 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/pixelator/config/__init__.py b/src/pixelator/config/__init__.py index 753f402b..e0a4244f 100644 --- a/src/pixelator/config/__init__.py +++ b/src/pixelator/config/__init__.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" from pixelator.config.assay import ( Assay, diff --git a/src/pixelator/config/config_instance.py b/src/pixelator/config/config_instance.py index 9e9ad1a6..9d95757e 100644 --- a/src/pixelator/config/config_instance.py +++ b/src/pixelator/config/config_instance.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" from pixelator.config.config_class import ( Config, diff --git a/src/pixelator/config/utils.py b/src/pixelator/config/utils.py index a03ce0ce..7fd77539 100644 --- a/src/pixelator/config/utils.py +++ b/src/pixelator/config/utils.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" from pathlib import Path from typing import Any diff --git a/src/pixelator/demux/__init__.py b/src/pixelator/demux/__init__.py index 6d5e1d4d..24a82f96 100644 --- a/src/pixelator/demux/__init__.py +++ b/src/pixelator/demux/__init__.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" from pixelator.demux.process import demux_fastq diff --git a/src/pixelator/qc/__init__.py b/src/pixelator/qc/__init__.py index 2b341f1c..5e0bc386 100644 --- a/src/pixelator/qc/__init__.py +++ b/src/pixelator/qc/__init__.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" from pixelator.qc.process import adapter_qc_fastq, qc_fastq diff --git a/src/pixelator/report/workdir.py b/src/pixelator/report/workdir.py index 968c133f..66c6eb3d 100644 --- a/src/pixelator/report/workdir.py +++ b/src/pixelator/report/workdir.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" import itertools import logging from collections import defaultdict diff --git a/src/pixelator/resources/__init__.py b/src/pixelator/resources/__init__.py index 900f523a..498548f0 100644 --- a/src/pixelator/resources/__init__.py +++ b/src/pixelator/resources/__init__.py @@ -1,2 +1 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" diff --git a/src/pixelator/test_utils/__init__.py b/src/pixelator/test_utils/__init__.py index ca8f4223..f258864e 100644 --- a/src/pixelator/test_utils/__init__.py +++ b/src/pixelator/test_utils/__init__.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" from .adapterqc import BaseAdapterQCTestsMixin from .amplicon import BaseAmpliconTestsMixin from .analysis import BaseAnalysisTestsMixin diff --git a/src/pixelator/test_utils/adapterqc.py b/src/pixelator/test_utils/adapterqc.py index f54379dc..a8d82452 100644 --- a/src/pixelator/test_utils/adapterqc.py +++ b/src/pixelator/test_utils/adapterqc.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" import logging import pytest diff --git a/src/pixelator/test_utils/amplicon.py b/src/pixelator/test_utils/amplicon.py index 9555a7c0..910ae0f9 100644 --- a/src/pixelator/test_utils/amplicon.py +++ b/src/pixelator/test_utils/amplicon.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" import logging from pathlib import Path diff --git a/src/pixelator/test_utils/analysis.py b/src/pixelator/test_utils/analysis.py index b8ad2b33..8b70c181 100644 --- a/src/pixelator/test_utils/analysis.py +++ b/src/pixelator/test_utils/analysis.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" import logging import pytest diff --git a/src/pixelator/test_utils/base.py b/src/pixelator/test_utils/base.py index ca0eccc0..5a20c16c 100644 --- a/src/pixelator/test_utils/base.py +++ b/src/pixelator/test_utils/base.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" from typing import Any, ClassVar, List from click.testing import Result as CliRunnerResult diff --git a/src/pixelator/test_utils/collapse.py b/src/pixelator/test_utils/collapse.py index 5af2e742..49abca92 100644 --- a/src/pixelator/test_utils/collapse.py +++ b/src/pixelator/test_utils/collapse.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" import logging from pathlib import Path diff --git a/src/pixelator/test_utils/config.py b/src/pixelator/test_utils/config.py index 9fa77a0d..e96d2f1f 100644 --- a/src/pixelator/test_utils/config.py +++ b/src/pixelator/test_utils/config.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" from pathlib import Path from typing import Any, Dict diff --git a/src/pixelator/test_utils/demux.py b/src/pixelator/test_utils/demux.py index 0716464a..292a8c87 100644 --- a/src/pixelator/test_utils/demux.py +++ b/src/pixelator/test_utils/demux.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" import logging from pathlib import Path diff --git a/src/pixelator/test_utils/workflow.py b/src/pixelator/test_utils/workflow.py index 640a8da4..95c191d2 100644 --- a/src/pixelator/test_utils/workflow.py +++ b/src/pixelator/test_utils/workflow.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" from pathlib import Path from . import ( diff --git a/src/pixelator/test_utils/workflow_context.py b/src/pixelator/test_utils/workflow_context.py index 77062b89..5b15877c 100644 --- a/src/pixelator/test_utils/workflow_context.py +++ b/src/pixelator/test_utils/workflow_context.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2023 Pixelgen Technologies AB. -""" +"""Copyright (c) 2023 Pixelgen Technologies AB.""" import logging import shutil from pathlib import Path From 2987663b4dcdb6762bfab9683a8adfacbd5b914c Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 15:47:52 +0100 Subject: [PATCH 07/13] Ignore all doc rules in `test_utils` Since this is only used in the tests we don't need to lint the docs here. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 3fca4916..2cc44400 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -121,6 +121,7 @@ exclude = ["docs/conf.py"] # Since click uses a different layout for the docs strings to generate the # cli docs, we ignore these rules here. "src/pixelator/cli/**" = ["D200", "D212", "D400", "D415"] +"src/pixelator/test_utils/**" = ["D"] [tool.poetry-dynamic-versioning] enable = true From 4f65971aa5ad126bff3198a1f61cc9233842f5d3 Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 15:57:30 +0100 Subject: [PATCH 08/13] Remove exceptions module --- .flake8 | 2 +- src/pixelator/collapse/process.py | 23 ++++++++++++++++++++++- src/pixelator/exception.py | 25 ------------------------- 3 files changed, 23 insertions(+), 27 deletions(-) delete mode 100644 src/pixelator/exception.py diff --git a/.flake8 b/.flake8 index 32658f7c..54ee37fe 100644 --- a/.flake8 +++ b/.flake8 @@ -1,6 +1,6 @@ [flake8] -extend-ignore = E501,E402,W503,E203,DOC301,DOC502 +extend-ignore = E501,E402,W503,E203,DOC301,DOC502,D213, D203 exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,cue.mod docstring-convention = all style = sphinx diff --git a/src/pixelator/collapse/process.py b/src/pixelator/collapse/process.py index ed8697dd..96fb587c 100644 --- a/src/pixelator/collapse/process.py +++ b/src/pixelator/collapse/process.py @@ -5,6 +5,7 @@ Copyright (c) 2023 Pixelgen Technologies AB. """ + import logging import tempfile import typing @@ -29,8 +30,10 @@ from umi_tools._dedup_umi import edit_distance from umi_tools.network import breadth_first_search +from pathlib import Path +from typing import Union + from pixelator.collapse.constants import SEED -from pixelator.exception import FileFqGzEmpty from pixelator.types import PathType from pixelator.utils import gz_size @@ -43,6 +46,24 @@ UniqueFragmentToUpiB = dict[UniqueFragment, list[UpiB]] +class FileFqGzEmpty(Exception): + """Class to manage empty fastq.gz file exceptions. + + Attributes + ---------- + msg: the error message to output + fname: the name of the file + size: the size of the file uncompressed (should be 0) + + """ + + def __init__(self, msg: str, fname: Union[str, Path], size: int): + """Initialize the exception.""" + self.msg = msg + self.fname = fname + self.size = size + + class CollapsedFragment(typing.NamedTuple): """A collapsed fragment. diff --git a/src/pixelator/exception.py b/src/pixelator/exception.py deleted file mode 100644 index 17f89119..00000000 --- a/src/pixelator/exception.py +++ /dev/null @@ -1,25 +0,0 @@ -"""This module contains all the extra exception classes and handling -defined by pixelator. - -Copyright (c) 2022 Pixelgen Technologies AB. -""" - -from pathlib import Path -from typing import Union - - -class FileFqGzEmpty(Exception): - """Class to manage empty fastq.gz file exceptions. - - Attributes - ---------- - msg: the error message to output - fname: the name of the file - size: the size of the file uncompressed (should be 0) - - """ - - def __init__(self, msg: str, fname: Union[str, Path], size: int): - self.msg = msg - self.fname = fname - self.size = size From 5da1f861b54fec4501008d913386cf7522c95d9d Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 16:00:24 +0100 Subject: [PATCH 09/13] Fix more docs --- src/pixelator/config/config_class.py | 6 ++++-- src/pixelator/config/plugin.py | 2 ++ src/pixelator/demux/process.py | 6 ++++-- src/pixelator/qc/process.py | 10 +++++++--- src/pixelator/report/workdir.py | 3 +++ tasks.py | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/pixelator/config/config_class.py b/src/pixelator/config/config_class.py index 888d193f..959ac62d 100644 --- a/src/pixelator/config/config_class.py +++ b/src/pixelator/config/config_class.py @@ -1,8 +1,8 @@ -"""This module contains classes and functions related to -the configuration file for pixelator (assay settings). +"""Module contains classes and functions related to the configuration file for pixelator (assay settings). Copyright (c) 2022 Pixelgen Technologies AB. """ + from __future__ import annotations import itertools @@ -33,6 +33,7 @@ def __init__( assays: Optional[List[Assay]] = None, panels: Optional[List[AntibodyPanel]] = None, ) -> None: + """Initialize the config object.""" self.assays: Dict[str, Assay] = {} self.panels: typing.MutableMapping[str, List[AntibodyPanel]] = defaultdict(list) @@ -50,6 +51,7 @@ def load_assay(self, path: PathType) -> None: self.assays[assay.name] = assay def load_panel_file(self, path: PathType) -> None: + """Load the panel file.""" panel = AntibodyPanel.from_csv(path) key = panel.name if panel.name is not None else str(panel.filename) self.panels[key].append(panel) diff --git a/src/pixelator/config/plugin.py b/src/pixelator/config/plugin.py index 6a8503ca..da896943 100644 --- a/src/pixelator/config/plugin.py +++ b/src/pixelator/config/plugin.py @@ -2,6 +2,7 @@ Copyright (c) 2023 Pixelgen Technologies AB. """ + from __future__ import annotations import logging from typing import Generator, List, TYPE_CHECKING, Union @@ -45,6 +46,7 @@ def fetch_config_plugins() -> Generator[importlib.metadata.EntryPoint, None, Non def load_config_plugins(config: Config) -> Config: + """Load all config plugins.""" new_config = config for entry_point in fetch_config_plugins(): diff --git a/src/pixelator/demux/process.py b/src/pixelator/demux/process.py index e88ed351..ba73a00f 100644 --- a/src/pixelator/demux/process.py +++ b/src/pixelator/demux/process.py @@ -1,4 +1,4 @@ -"""This module contains functions for demultiplex reads belonging to antibody panels. +"""Module that contains functions for demultiplex reads belonging to antibody panels. Copyright (c) 2022 Pixelgen Technologies AB. """ @@ -29,7 +29,9 @@ def demux_fastq( cores: int, verbose: bool, ) -> None: - """This function is a wrapper around `cutadapt` to process a `fastq` + """Demultiplex the input fastq file into separate files based on the barcodes. + + This function is a wrapper around `cutadapt` to process a `fastq` file with molecular pixelation data. A `fasta` file with the barcodes to use to demultiplex must be provided (antibody name and its sequence). The fastq will be processed to demultiplex its barcode with the ones diff --git a/src/pixelator/qc/process.py b/src/pixelator/qc/process.py index 4d636f8c..692a59f4 100644 --- a/src/pixelator/qc/process.py +++ b/src/pixelator/qc/process.py @@ -1,4 +1,4 @@ -"""This module contains functions for processing and QC any MPX amplicon design. +"""Module that contains functions for processing and QC any MPX amplicon design. Copyright (c) 2022 Pixelgen Technologies AB. """ @@ -32,7 +32,9 @@ def qc_fastq( remove_polyg: bool, verbose: bool, ) -> None: - """This function is a wrapper around `fastp` to pre-process a `fastq` + """Filter reads from fastq files on the provided quality criteria. + + This function is a wrapper around `fastp` to pre-process a `fastq` file. Duplicated sequences are removed, polyG sequences of length >= 5 are trimmed. Some filters are used to discard reads (maximum and minimum read length and the maximum number of Ns in a read). @@ -146,7 +148,9 @@ def adapter_qc_fastq( cores: int, verbose: bool, ) -> None: - """This function is a wrapper around `cutadapt` to process a `fastq` + """Filter reads from fastq files that do not have PBS1/2 sequences. + + This function is a wrapper around `cutadapt` to process a `fastq` file with molecular pixelation data. The provided PBS1/2 sequences will be searched in the reads and only the reads that contain both sequences will be kept. diff --git a/src/pixelator/report/workdir.py b/src/pixelator/report/workdir.py index 66c6eb3d..90edf133 100644 --- a/src/pixelator/report/workdir.py +++ b/src/pixelator/report/workdir.py @@ -1,4 +1,5 @@ """Copyright (c) 2023 Pixelgen Technologies AB.""" + import itertools import logging from collections import defaultdict @@ -17,6 +18,7 @@ class PixelatorWorkdir: } def __init__(self, basedir: PathType): + """Initialize the workdir object.""" self.basedir = Path(basedir) self._metadata = self._collect_metadata_files() @@ -74,6 +76,7 @@ def _collect_metadata_files(self) -> Dict[str, List[Path]]: return {**metadata_files_index} def metadata_files(self, sample: Optional[str] = None) -> List[Path]: + """Get a list of metadata files.""" if sample: return self._metadata[sample] diff --git a/tasks.py b/tasks.py index 4b9eb588..80ff81f7 100644 --- a/tasks.py +++ b/tasks.py @@ -165,7 +165,7 @@ def clean_tests(c): @task(pre=[clean_build, clean_python, clean_tests, clean_docs]) def clean(c): - """Runs all clean sub-tasks.""" + """Run all clean sub-tasks.""" pass From 4ddfa5a038d8a7f020dfb7bbd891ee3d8b197b54 Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 16:13:13 +0100 Subject: [PATCH 10/13] Remove unused method --- src/pixelator/config/assay.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/pixelator/config/assay.py b/src/pixelator/config/assay.py index f19098f4..699c872b 100644 --- a/src/pixelator/config/assay.py +++ b/src/pixelator/config/assay.py @@ -382,10 +382,6 @@ def get_sequence(self) -> str: return "".join(s) - def update_spec(self): - for r in self.assay_spec: - r.update_attr() - def get_region_by_id(self, region_id: str) -> Optional[Region]: """Retrieve a region by its id. From e6d4b67b8b2dfbb351ff66dee98b49fea5113ae4 Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 16:17:53 +0100 Subject: [PATCH 11/13] More docs --- src/pixelator/cli/plugin.py | 6 +++--- src/pixelator/config/assay.py | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pixelator/cli/plugin.py b/src/pixelator/cli/plugin.py index 91cacd2b..238f20bc 100644 --- a/src/pixelator/cli/plugin.py +++ b/src/pixelator/cli/plugin.py @@ -3,6 +3,7 @@ Copyright (c) 2022 Pixelgen Technologies AB. """ + import importlib.metadata try: @@ -45,10 +46,9 @@ def fetch_cli_plugins() -> Generator[EntryPoint, None, None]: def add_cli_plugins(group: Group) -> None: - """ - Add all cli plugins we can find to the provided group - :param group: An instance of `click.Group` to add sub commands to + """Add all cli plugins we can find to the provided group. + :param group: An instance of `click.Group` to add sub commands to :returns: None """ for entrypoint in fetch_cli_plugins(): diff --git a/src/pixelator/config/assay.py b/src/pixelator/config/assay.py index 699c872b..f243a453 100644 --- a/src/pixelator/config/assay.py +++ b/src/pixelator/config/assay.py @@ -182,6 +182,7 @@ def get_max_length(self): return self.get_len()[1] def update_attr(self): + """Update the attributes of the region.""" if self.regions: for idx, r in enumerate(self.regions): r.update_attr() @@ -191,6 +192,7 @@ def update_attr(self): return def __repr__(self) -> str: + """Return str representation of the instance.""" d = { "region_id": self.region_id, "region_type": self.region_type, @@ -204,6 +206,7 @@ def __repr__(self) -> str: return f"{d}" def to_dict(self): + """Return a dictionary representation of the region.""" d = { "region_id": self.region_id, "region_type": self.region_type, @@ -288,6 +291,7 @@ class Assay: """ def __init__(self, name: str, assay_spec: Optional[List[Region]] = None): + """Initialize an assay.""" self.name = name self.assay_spec: List[Region] = assay_spec or [] @@ -372,6 +376,7 @@ def from_yaml(cls, filename: PathType) -> "Assay": return cls._load_assay_model(checked_obj) def to_json(self): + """Return a json representation of the assay.""" return json.dumps(self, default=lambda o: o.__dict__, sort_keys=False, indent=4) def get_sequence(self) -> str: From d8f206049595145f4c21acd0e9ac304782b0bda6 Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 16:18:40 +0100 Subject: [PATCH 12/13] More docs --- src/pixelator/annotate/constants.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pixelator/annotate/constants.py b/src/pixelator/annotate/constants.py index 0c039588..259c4230 100644 --- a/src/pixelator/annotate/constants.py +++ b/src/pixelator/annotate/constants.py @@ -1,5 +1,4 @@ -"""This module contains constants used as part of the annotation -modules. +"""Constants used as part of the annotation modules. Copyright (c) 2022 Pixelgen Technologies AB. """ From 12ada02a8cb186af3408312f67f8dd0df4cb9680 Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Wed, 7 Feb 2024 16:23:10 +0100 Subject: [PATCH 13/13] Fix docs --- src/pixelator/annotate/aggregates.py | 6 ++++-- src/pixelator/annotate/cell_calling.py | 30 +++++++++++++++++--------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/pixelator/annotate/aggregates.py b/src/pixelator/annotate/aggregates.py index 5230f5a5..5317e5be 100644 --- a/src/pixelator/annotate/aggregates.py +++ b/src/pixelator/annotate/aggregates.py @@ -1,4 +1,4 @@ -"""This module contains functions for finding aggregates. +"""Functions for finding aggregates. Copyright (c) 2022 Pixelgen Technologies AB. """ @@ -46,7 +46,9 @@ def specificity_tau(matrix: np.ndarray) -> np.ndarray: def call_aggregates(adata: AnnData, inplace: bool = True) -> Optional[AnnData]: - """We defined aggregates as components where either: + """Call aggregates on the adata instance. + + We defined aggregates as components where either: - A single or a handful of markers account for almost all of the count data. These can likely be attributed to single antibodies forming aggregates - Low tau scores, meaning a an even number of counts for multiple markers. diff --git a/src/pixelator/annotate/cell_calling.py b/src/pixelator/annotate/cell_calling.py index 6712295f..bc12735c 100644 --- a/src/pixelator/annotate/cell_calling.py +++ b/src/pixelator/annotate/cell_calling.py @@ -1,4 +1,4 @@ -"""This module contains functions for doing size-based cell calling. +"""Functions for doing size-based cell calling. Copyright (c) 2022 Pixelgen Technologies AB. """ @@ -25,7 +25,9 @@ def find_component_size_limits( component_sizes: np.ndarray, direction: Literal["lower", "upper"], ) -> Optional[int]: - """This function will attempt to find a cutoff for a distribution of component sizes. + """Find component size limits. + + This function will attempt to find a cutoff for a distribution of component sizes. The direction of the cut-off is determined by the `direction` parameter (lower for min size and upper for max size). @@ -64,7 +66,9 @@ def find_component_size_limits( """ def log_size_and_rank(df: pd.DataFrame) -> pd.DataFrame: - """Rank component sizes by size, sort by their rank, and compute the + """Rank components by size. + + Rank component sizes by size, sort by their rank, and compute the log10 of both the sizes and ranks. The input dataframe must contain a `size` column with the component sizes. A new dataframe is returned with two new columns `log10_size` and `log10_rank`. @@ -76,7 +80,9 @@ def log_size_and_rank(df: pd.DataFrame) -> pd.DataFrame: return df def smooth(df: pd.DataFrame, x_var: str, y_var: str) -> pd.DataFrame: - """Calculate a smoothing spline of df[x_var] ~ df[y_var] + """Create a smoothing spline. + + Calculate a smoothing spline of df[x_var] ~ df[y_var] to make it possible to calculate a less unstable derivate. The input dataframe must contain the `x_var` and `y_var` columns, a new column `smooth` is added to the returned @@ -92,7 +98,9 @@ def smooth(df: pd.DataFrame, x_var: str, y_var: str) -> pd.DataFrame: return df def derivatives(df: pd.DataFrame, x_var: str) -> pd.DataFrame: - """Calculate the first and second derivatives of the smoothed + """Calculate first and second derivatives. + + Calculate the first and second derivatives of the smoothed `x_var` variable. The input dataframe must contain the `x_var` and `smooth` columns. The returned dataframe contains two new columns `der1` and `der2` with the @@ -103,7 +111,9 @@ def derivatives(df: pd.DataFrame, x_var: str) -> pd.DataFrame: return df def find_der1_vs_der2_outliers(df: pd.DataFrame) -> pd.Series: - """Find the distance from origo to each component in + """Find the distance from origo to each component. + + Find the distance from origo to each component in the space df[der1] ~ df[der2], then try to find outliers in the upper part of component ranks, by looking at the standard deviation of the distances. @@ -122,10 +132,10 @@ def find_der1_vs_der2_outliers(df: pd.DataFrame) -> pd.Series: return df["rank"] == rank - 1 def minimum_der2(df: pd.DataFrame) -> pd.Series: - """Find argmin element. The function returns - a boolean Series where the global minimum - of `der2` evaluates to True. The input dataframe - must contain the `der2` column. + """Find argmin element. + + The function returns a boolean Series where the global minimum of `der2` evaluates + to True. The input dataframe must contain the `der2` column. """ return df["der2"] == np.nanmin(df["der2"])