From 5993093924f3451bb420e830dbd06e0c1be584ce Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Wed, 16 Oct 2024 17:54:25 +0200 Subject: [PATCH 1/5] Update the pyproject.toml --- pyproject_scverse.toml | 95 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 pyproject_scverse.toml diff --git a/pyproject_scverse.toml b/pyproject_scverse.toml new file mode 100644 index 0000000..c0d1b7c --- /dev/null +++ b/pyproject_scverse.toml @@ -0,0 +1,95 @@ +[build-system] +build-backend = "hatchling.build" +requires = [ "hatchling" ] + +[project] +name = "fancypackage" +version = "0.0.1" +description = "Fancy Package" +readme = "README.md" +license = { file = "LICENSE" } +maintainers = [ + { name = "Jane Doe", email = "jane.doe@usa.com" }, +] +authors = [ + { name = "Jane Doe" }, +] +requires-python = ">=3.10" +classifiers = [ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +dependencies = [ + "anndata", + # for debug logging (referenced from the issue template) + "session-info", +] +optional-dependencies.dev = [ + "pre-commit", + "twine>=4.0.2", +] + +optional-dependencies.test = [ + "coverage", + "pytest", +] +# https://docs.pypi.org/project_metadata/#project-urls +urls.Homepage = "https://github.com/url/to/repo.git" +urls.Source = "https://github.com/url/to/repo.git" + +[tool.hatch.envs.default] +installer = "uv" +features = [ "dev" ] + +[tool.hatch.envs.hatch-test] +features = [ "test" ] + +[tool.ruff] +line-length = 120 +src = [ "src" ] +extend-include = [ "*.ipynb" ] + +format.docstring-code-format = true + +lint.select = [ + "B", # flake8-bugbear + "BLE", # flake8-blind-except + "C4", # flake8-comprehensions + "D", # pydocstyle + "E", # Error detected by Pycodestyle + "F", # Errors detected by Pyflakes + "I", # isort + "RUF100", # Report unused noqa directives + "TID", # flake8-tidy-imports + "UP", # pyupgrade + "W", # Warning detected by Pycodestyle +] +lint.ignore = [ + "B008", # Errors from function calls in argument defaults. These are fine when the result is immutable. + "D100", # Missing docstring in public module + "D104", # Missing docstring in public package + "D105", # __magic__ methods are often self-explanatory, allow missing docstrings + "D107", # Missing docstring in __init__ + # Disable one in each pair of mutually incompatible rules + "D203", # We don’t want a blank line before a class docstring + "D213", # <> We want docstrings to start immediately after the opening triple quote + "D400", # first line should end with a period [Bug: doesn’t work with single-line docstrings] + "D401", # First line should be in imperative mood; try rephrasing + "E501", # line too long -> we accept long comment lines; formatter gets rid of long code lines + "E731", # Do not assign a lambda expression, use a def -> lambda expression assignments are convenient + "E741", # allow I, O, l as variable names -> I is the identity matrix +] +lint.per-file-ignores."*/__init__.py" = [ "F401" ] +lint.per-file-ignores."docs/*" = [ "I" ] +lint.per-file-ignores."tests/*" = [ "D" ] +lint.pydocstyle.convention = "numpy" + +[tool.pytest.ini_options] +testpaths = [ "tests" ] +xfail_strict = true +addopts = [ + "--import-mode=importlib", # allow using test files with same name +] From 37800a1c996737eb1008ff6697dab09d2b3e4527 Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Wed, 16 Oct 2024 17:55:04 +0200 Subject: [PATCH 2/5] Rename the pyproject.toml --- pyproject.toml | 171 ++++++++++++++++++----------------------- pyproject_scverse.toml | 95 ----------------------- 2 files changed, 76 insertions(+), 190 deletions(-) delete mode 100644 pyproject_scverse.toml diff --git a/pyproject.toml b/pyproject.toml index 344c30c..c0d1b7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,114 +1,95 @@ [build-system] -requires = ['setuptools', 'setuptools_scm'] -build-backend = 'setuptools.build_meta' +build-backend = "hatchling.build" +requires = [ "hatchling" ] [project] name = "fancypackage" -version = "0.0.0" +version = "0.0.1" description = "Fancy Package" readme = "README.md" -requires-python = ">=3.10" -license = {file = "LICENSE"} +license = { file = "LICENSE" } +maintainers = [ + { name = "Jane Doe", email = "jane.doe@usa.com" }, +] authors = [ - {name = "Jane Doe"}, + { name = "Jane Doe" }, ] -maintainers = [ - {name = "Jane Doe", email = "jane.doe@usa.com"}, +requires-python = ">=3.10" +classifiers = [ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] -urls.Source = "https://github.com/url/to/repo.git" -urls.Home-page = "https://github.com/url/to/repo.git" dependencies = [ - "anndata", - "scanpy", + "anndata", + # for debug logging (referenced from the issue template) + "session-info", +] +optional-dependencies.dev = [ + "pre-commit", + "twine>=4.0.2", ] -[project.optional-dependencies] -dev = [ - "pre-commit", +optional-dependencies.test = [ + "coverage", + "pytest", ] +# https://docs.pypi.org/project_metadata/#project-urls +urls.Homepage = "https://github.com/url/to/repo.git" +urls.Source = "https://github.com/url/to/repo.git" -[tool.black] -line-length = 120 -include = '\.pyi?$|\.ipynb?$' -exclude = ''' -( - /( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | _build - | buck-out - | build - | dist - )/ -) -''' +[tool.hatch.envs.default] +installer = "uv" +features = [ "dev" ] -[tool.isort] -profile = "black" -use_parentheses = true -known_num = "networkx,numpy,pandas,scipy,sklearn,statmodels" -known_plot = "matplotlib,mplscience,mpl_toolkits,seaborn" -known_bio = "anndata,scanpy" -sections = "FUTURE,STDLIB,THIRDPARTY,NUM,PLOT,BIO,FIRSTPARTY,LOCALFOLDER" -no_lines_before = "LOCALFOLDER" -balanced_wrapping = true -length_sort = "0" -indent = " " -float_to_top = true -order_by_type = false +[tool.hatch.envs.hatch-test] +features = [ "test" ] [tool.ruff] -src = ["."] -line-length = 119 -target-version = "py38" -select = [ - "F", # Errors detected by Pyflakes - "E", # Error detected by Pycodestyle - "W", # Warning detected by Pycodestyle - "D", # pydocstyle - "B", # flake8-bugbear - "TID", # flake8-tidy-imports - "C4", # flake8-comprehensions - "BLE", # flake8-blind-except - "UP", # pyupgrade - "RUF100", # Report unused noqa directives +line-length = 120 +src = [ "src" ] +extend-include = [ "*.ipynb" ] + +format.docstring-code-format = true + +lint.select = [ + "B", # flake8-bugbear + "BLE", # flake8-blind-except + "C4", # flake8-comprehensions + "D", # pydocstyle + "E", # Error detected by Pycodestyle + "F", # Errors detected by Pyflakes + "I", # isort + "RUF100", # Report unused noqa directives + "TID", # flake8-tidy-imports + "UP", # pyupgrade + "W", # Warning detected by Pycodestyle +] +lint.ignore = [ + "B008", # Errors from function calls in argument defaults. These are fine when the result is immutable. + "D100", # Missing docstring in public module + "D104", # Missing docstring in public package + "D105", # __magic__ methods are often self-explanatory, allow missing docstrings + "D107", # Missing docstring in __init__ + # Disable one in each pair of mutually incompatible rules + "D203", # We don’t want a blank line before a class docstring + "D213", # <> We want docstrings to start immediately after the opening triple quote + "D400", # first line should end with a period [Bug: doesn’t work with single-line docstrings] + "D401", # First line should be in imperative mood; try rephrasing + "E501", # line too long -> we accept long comment lines; formatter gets rid of long code lines + "E731", # Do not assign a lambda expression, use a def -> lambda expression assignments are convenient + "E741", # allow I, O, l as variable names -> I is the identity matrix ] -ignore = [ - # line too long -> we accept long comment lines; black gets rid of long code lines - "E501", - # Do not assign a lambda expression, use a def -> lambda expression assignments are convenient - "E731", - # allow I, O, l as variable names -> I is the identity matrix - "E741", - # Missing docstring in public package - "D104", - # Missing docstring in public module - "D100", - # Missing docstring in __init__ - "D107", - # Errors from function calls in argument defaults. These are fine when the result is immutable. - "B008", - # __magic__ methods are are often self-explanatory, allow missing docstrings - "D105", - # first line should end with a period [Bug: doesn't work with single-line docstrings] - "D400", - # First line should be in imperative mood; try rephrasing - "D401", - ## Disable one in each pair of mutually incompatible rules - # We don’t want a blank line before a class docstring - "D203", - # We want docstrings to start immediately after the opening triple quote - "D213", - # Missing argument description in the docstring TODO: enable - "D417", - # Unable to detect undefined names - "F403", - # Underfined, or defined from star imports: module - "F405", - # Within an except clause, raise exceptions with `raise ... from err` - "B904", +lint.per-file-ignores."*/__init__.py" = [ "F401" ] +lint.per-file-ignores."docs/*" = [ "I" ] +lint.per-file-ignores."tests/*" = [ "D" ] +lint.pydocstyle.convention = "numpy" + +[tool.pytest.ini_options] +testpaths = [ "tests" ] +xfail_strict = true +addopts = [ + "--import-mode=importlib", # allow using test files with same name ] diff --git a/pyproject_scverse.toml b/pyproject_scverse.toml deleted file mode 100644 index c0d1b7c..0000000 --- a/pyproject_scverse.toml +++ /dev/null @@ -1,95 +0,0 @@ -[build-system] -build-backend = "hatchling.build" -requires = [ "hatchling" ] - -[project] -name = "fancypackage" -version = "0.0.1" -description = "Fancy Package" -readme = "README.md" -license = { file = "LICENSE" } -maintainers = [ - { name = "Jane Doe", email = "jane.doe@usa.com" }, -] -authors = [ - { name = "Jane Doe" }, -] -requires-python = ">=3.10" -classifiers = [ - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", -] -dependencies = [ - "anndata", - # for debug logging (referenced from the issue template) - "session-info", -] -optional-dependencies.dev = [ - "pre-commit", - "twine>=4.0.2", -] - -optional-dependencies.test = [ - "coverage", - "pytest", -] -# https://docs.pypi.org/project_metadata/#project-urls -urls.Homepage = "https://github.com/url/to/repo.git" -urls.Source = "https://github.com/url/to/repo.git" - -[tool.hatch.envs.default] -installer = "uv" -features = [ "dev" ] - -[tool.hatch.envs.hatch-test] -features = [ "test" ] - -[tool.ruff] -line-length = 120 -src = [ "src" ] -extend-include = [ "*.ipynb" ] - -format.docstring-code-format = true - -lint.select = [ - "B", # flake8-bugbear - "BLE", # flake8-blind-except - "C4", # flake8-comprehensions - "D", # pydocstyle - "E", # Error detected by Pycodestyle - "F", # Errors detected by Pyflakes - "I", # isort - "RUF100", # Report unused noqa directives - "TID", # flake8-tidy-imports - "UP", # pyupgrade - "W", # Warning detected by Pycodestyle -] -lint.ignore = [ - "B008", # Errors from function calls in argument defaults. These are fine when the result is immutable. - "D100", # Missing docstring in public module - "D104", # Missing docstring in public package - "D105", # __magic__ methods are often self-explanatory, allow missing docstrings - "D107", # Missing docstring in __init__ - # Disable one in each pair of mutually incompatible rules - "D203", # We don’t want a blank line before a class docstring - "D213", # <> We want docstrings to start immediately after the opening triple quote - "D400", # first line should end with a period [Bug: doesn’t work with single-line docstrings] - "D401", # First line should be in imperative mood; try rephrasing - "E501", # line too long -> we accept long comment lines; formatter gets rid of long code lines - "E731", # Do not assign a lambda expression, use a def -> lambda expression assignments are convenient - "E741", # allow I, O, l as variable names -> I is the identity matrix -] -lint.per-file-ignores."*/__init__.py" = [ "F401" ] -lint.per-file-ignores."docs/*" = [ "I" ] -lint.per-file-ignores."tests/*" = [ "D" ] -lint.pydocstyle.convention = "numpy" - -[tool.pytest.ini_options] -testpaths = [ "tests" ] -xfail_strict = true -addopts = [ - "--import-mode=importlib", # allow using test files with same name -] From 4bf032f8c4f97571df143004b097838c88accc93 Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Wed, 16 Oct 2024 17:59:50 +0200 Subject: [PATCH 3/5] Update pre-commit configs --- .pre-commit-config.yaml | 90 +++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11090d3..ff17096 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,54 +1,46 @@ fail_fast: false default_language_version: - python: python3 + python: python3 default_stages: - - commit - - push + - pre-commit + - pre-push minimum_pre_commit_version: 2.16.0 repos: - - repo: https://github.com/psf/black - rev: "23.1.0" - hooks: - - id: black-jupyter - - repo: https://github.com/asottile/blacken-docs - rev: 1.13.0 - hooks: - - id: blacken-docs - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.4 - hooks: - - id: prettier - # Newer versions of node don't work on systems that have an older version of GLIBC - # (in particular Ubuntu 18.04 and Centos 7) - # EOL of Centos 7 is in 2024-06, we can probably get rid of this then. - # See https://github.com/scverse/cookiecutter-scverse/issues/143 and - # https://github.com/jupyterlab/jupyterlab/issues/12675 - language_version: "17.9.1" - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.253 - hooks: - - id: ruff - args: [--fix, --exit-non-zero-on-fix] - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: detect-private-key - - id: check-ast - - id: end-of-file-fixer - - id: mixed-line-ending - args: [--fix=lf] - - id: trailing-whitespace - - id: check-case-conflict - - repo: local - hooks: - - id: forbid-to-commit - name: Don't commit rej files - entry: | - Cannot commit .rej files. These indicate merge conflicts that arise during automated template updates. - Fix the merge conflicts manually and remove the .rej files. - language: fail - files: '.*\.rej$' + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 + hooks: + - id: prettier + - repo: https://github.com/tox-dev/pyproject-fmt + rev: "2.3.1" + hooks: + - id: pyproject-fmt + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.9 + hooks: + - id: ruff + types_or: [python, pyi, jupyter] + args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format + types_or: [python, pyi, jupyter] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: detect-private-key + - id: check-ast + - id: end-of-file-fixer + - id: mixed-line-ending + args: [--fix=lf] + - id: trailing-whitespace + - id: check-case-conflict + # Check that there are no merge conflicts (could be generated by template sync) + - id: check-merge-conflict + args: [--assume-in-merge] + - repo: local + hooks: + - id: forbid-to-commit + name: Don't commit rej files + entry: | + Cannot commit .rej files. These indicate merge conflicts that arise during automated template updates. + Fix the merge conflicts manually and remove the .rej files. + language: fail + files: '.*\.rej$' From f7a95664ba9e92e61c6be93e81a97bbb03e0e2af Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Wed, 16 Oct 2024 18:00:51 +0200 Subject: [PATCH 4/5] Update the editorconfig --- .editorconfig | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.editorconfig b/.editorconfig index 3af5212..66678e3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,3 @@ -# EditorConfig is awesome: https://EditorConfig.org - -# top-most EditorConfig file root = true [*] @@ -11,10 +8,8 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[makefile] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true +[{*.{yml,yaml,toml},.cruft.json}] +indent_size = 2 + +[Makefile] indent_style = tab -indent_size = 4 From 6137296aaf5f7f7864b2712aebce5c2b6563dd99 Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Wed, 16 Oct 2024 18:05:16 +0200 Subject: [PATCH 5/5] Add a formatting file --- .prettierrc.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .prettierrc.yaml diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 0000000..9aaffcb --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,7 @@ +overrides: + # JSON with comments and trailing commas + - files: .vscode/*.json + options: + parser: json5 + quoteProps: preserve + singleQuote: false