Skip to content

Commit

Permalink
chore: update cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
wpk committed Jan 8, 2025
1 parent 6174c20 commit f9f529f
Show file tree
Hide file tree
Showing 16 changed files with 362 additions and 107 deletions.
4 changes: 2 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/usnistgov/cookiecutter-nist-python.git",
"commit": "cb7a67e2b67f7d72881d116b3e54fcac3016a9ab",
"commit": "b05f94a53ee9bba9c456a75d61fb8639b847dcb1",
"checkout": "develop",
"context": {
"cookiecutter": {
Expand All @@ -19,7 +19,7 @@
"__answers": "",
"_copy_without_render": [],
"_template": "https://github.com/usnistgov/cookiecutter-nist-python.git",
"_commit": "cb7a67e2b67f7d72881d116b3e54fcac3016a9ab"
"_commit": "b05f94a53ee9bba9c456a75d61fb8639b847dcb1"
}
},
"directory": null
Expand Down
13 changes: 7 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ repos:
hooks:
- id: pyproject-fmt
args: [--indent=4, --keep-full-version]
files: ^pyproject.toml$
files: ""
types: [toml]
exclude: ^tests/data

# * Prettier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier
alias: markdownlint
stages: [pre-commit]
additional_dependencies:
- prettier-plugin-toml

# * Markdown
- repo: https://github.com/DavidAnson/markdownlint-cli2
Expand Down Expand Up @@ -81,6 +81,7 @@ repos:
additional_dependencies: [tomli]
args: [-I, docs/spelling_wordlist.txt]
exclude_types: [jupyter]
exclude: ^uv[.]lock$|^requirements

# * Commit message
- repo: https://github.com/commitizen-tools/commitizen
Expand All @@ -104,4 +105,4 @@ repos:
hooks:
- id: typos
stages: [manual]
exclude: "[.]ipynb$"
exclude: "[.]ipynb$|^uv[.]lock$|^requirements"
56 changes: 56 additions & 0 deletions .pylintrc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[tool.pylint]
ignore = [ "_implementation.py" ]

[tool.pylint.similarities]
ignore-imports = "yes"

[tool.pylint.basic]
no-docstring-rgx = "__.*__|test[A-Z_].*|_decorator|_wrapper|_.*__.*"

[tool.pylint.classes]
defining-attr-methods = [
"__init__",
"__new__",
"__post_init__",
"setUp",
"reset",
"_reset",
]

[tool.pylint.design]
max-args = 35
max-attributes = 40
max-bool-expr = 5
max-branches = 50
max-locals = 50
max-parents = 12
max-positional-arguments = 35
max-public-methods = 500
max-returns = 20
max-statements = 150
min-public-methods = 0

[tool.pylint."messages control"]
enable = [ "useless-suppression" ]
disable = [
# defer to ruff
"line-too-long",
"missing-module-docstring",
"missing-function-docstring",
"redefined-outer-name",
"unused-argument",
# Questionable things, but it's ok, I don't need to be told:
"import-outside-toplevel",
"superfluous-parens",
"too-many-lines",
# Messages that are noisy for now, eventually maybe we'll turn them on:
"invalid-name",
# "protected-access",
"unspecified-encoding",
"consider-using-f-string",
# "duplicate-code",
# "cyclic-import",
]

[tool.pylint.reports]
output-format = "colorized"
26 changes: 17 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ dev: _dev install-kernel
# * Testing --------------------------------------------------------------------
.PHONY: test coverage
test: ## run tests quickly with the default Python
uv run --frozen pytest -x -v
uv run --frozen pytest

test-accept: ## run tests and accept doctest results. (using pytest-accept)
DOCFILLER_SUB=False uv run --frozen pytest -v --accept
Expand All @@ -128,21 +128,24 @@ requirements: ## rebuild all requirements/environment files


# * Typing ---------------------------------------------------------------------
.PHONY: mypy pyright
.PHONY: mypy pyright pyright-watch pylint _typecheck typecheck
mypy: ## Run mypy
$(UVXRUN) $(UVXRUN_OPTS) -c mypy
pyright: ## Run pyright
$(UVXRUN) $(UVXRUN_OPTS) -c pyright
pyright-watch: ## Run pyright in watch mode
$(UVXRUN) $(UVXRUN_OPTS) -c "pyright -w"
typecheck: ## Run mypy and pyright
pylint: ## Run pylint
uv run pylint src tests
_typecheck:
$(UVXRUN) $(UVXRUN_OPTS) -c mypy -c pyright
typecheck: _typecheck pylint ## Run mypy and pyright

.PHONY: typecheck-tools
typecheck-tools:
uv run pylint noxfile.py tools
$(UVXRUN) $(UVXRUN_OPTS) -c "mypy --strict" -c pyright -- noxfile.py tools/*.py


# * NOX ------------------------------------------------------------------------
# ** docs
.PHONY: docs-build docs-clean docs-clean-build docs-release
Expand All @@ -167,13 +170,15 @@ docs-linkcheck: ## check links
$(NOX) -s docs -- +d linkcheck

# ** typing
.PHONY: typing-mypy typing-pyright typing-typecheck
.PHONY: typing-mypy typing-pyright typing-pylint typing-typecheck
typing-mypy: ## run mypy mypy_args=...
$(NOX) -s typing -- +m mypy
typing-pyright: ## run pyright pyright_args=...
$(NOX) -s typing -- +m pyright
typing-pylint: ## run pylint
$(NOX) -s pylint -- +m pylint
typing-typecheck:
$(NOX) -s typing -- +m mypy pyright
$(NOX) -s typing -- +m mypy pyright pylint

# ** dist pypi
.PHONY: build testrelease release
Expand Down Expand Up @@ -216,17 +221,20 @@ list-dist: list-wheel list-sdist ## Cat out sdist and wheel contents
# * NOTEBOOK -------------------------------------------------------------------
NOTEBOOKS ?= examples/usage
# NOTE: use this because nested call back in nox has errors with uv run...
_NBQA_UVXRUN = $(shell which python) tools/uvxrun.py
_PYTHON = $(shell which python)
_NBQA_UVXRUN = $(_PYTHON) tools/uvxrun.py
NBQA = $(_NBQA_UVXRUN) $(UVXRUN_OPTS) -c "nbqa --nbqa-shell \"$(_NBQA_UVXRUN)\" $(NOTEBOOKS) $(UVXRUN_OPTS) $(_NBQA)"
.PHONY: mypy-notebook pyright-notebook typecheck-notebook test-notebook
.PHONY: mypy-notebook pyright-notebook pylint-notebook typecheck-notebook test-notebook
mypy-notebook: _NBQA = -c mypy
mypy-notebook: ## run nbqa mypy
$(NBQA)
pyright-notebook: _NBQA = -c pyright
pyright-notebook: ## run nbqa pyright
$(NBQA)
pylint-notebook:: ## run nbqa pylint
$(_NBQA_UVXRUN) $(UVXRUN_OPTS) -c "nbqa --nbqa-shell \"$(_PYTHON) -m pylint\" $(NOTEBOOKS)"
typecheck-notebook: _NBQA = -c mypy -c pyright
typecheck-notebook: ## run nbqa mypy/pyright
typecheck-notebook: pylint-notebook ## run nbqa mypy/pyright
$(NBQA)
test-notebook: ## run pytest --nbval
uv run --frozen pytest --nbval --nbval-current-env --nbval-sanitize-with=config/nbval.ini --dist loadscope -x $(NOTEBOOKS)
Expand Down
50 changes: 29 additions & 21 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=wrong-import-position
"""Config file for nox."""

# * Imports ----------------------------------------------------------------------------
Expand All @@ -6,16 +7,8 @@
import shlex
import shutil
import sys
from functools import lru_cache, partial, wraps

from nox.virtualenv import CondaEnv

# Should only use on python version > 3.10
if sys.version_info < (3, 10):
msg = "python>=3.10 required"
raise RuntimeError(msg)

from dataclasses import dataclass
from functools import lru_cache, partial, wraps
from pathlib import Path
from typing import (
TYPE_CHECKING,
Expand All @@ -25,10 +18,16 @@
TypedDict,
)

# fmt: off
import nox
from nox.virtualenv import CondaEnv

sys.path.insert(0, ".")
from tools import uvxrun
from tools.dataclass_parser import DataclassParser, add_option, option
from tools.dataclass_parser import (
DataclassParser,
add_option,
option,
)
from tools.noxtools import (
check_for_change_manager,
combine_list_list_str,
Expand All @@ -41,17 +40,18 @@

sys.path.pop(0)

# make sure these after
import nox # type: ignore[unused-ignore,import]

# fmt: on

if TYPE_CHECKING:
from collections.abc import Callable, Iterable, Iterator, Sequence

from nox import Session


# Should only use on python version > 3.10
if sys.version_info < (3, 10):
msg = "python>=3.10 required"
raise RuntimeError(msg)

# * Names ------------------------------------------------------------------------------

PACKAGE_NAME = "pyproject2conda"
Expand Down Expand Up @@ -202,6 +202,7 @@ class SessionParams(DataclassParser):
"clean",
"mypy",
"pyright",
"pylint",
"pytype",
"all",
"mypy-notebook",
Expand Down Expand Up @@ -743,7 +744,7 @@ def lint(
# ** type checking
@nox.session(name="typing", **ALL_KWS)
@add_opts
def typing( # noqa: C901
def typing( # noqa: C901, PLR0912
session: nox.Session,
opts: SessionParams,
) -> None:
Expand All @@ -755,10 +756,10 @@ def typing( # noqa: C901

cmd = opts.typing or []
if not opts.typing_run and not opts.typing_run_internal and not cmd:
cmd = ["mypy", "pyright"]
cmd = ["mypy", "pyright", "pylint"]

if "all" in cmd:
cmd = ["mypy", "pyright", "pytype"]
cmd = ["mypy", "pyright", "pylint", "pytype"]

# set the cache directory for mypy
session.env["MYPY_CACHE_DIR"] = str(Path(session.create_tmp()) / ".mypy_cache")
Expand Down Expand Up @@ -792,6 +793,15 @@ def typing( # noqa: C901
run("mypy", "--color-output")
elif c == "pyright":
run("pyright")
elif c == "pylint":
session.run(
"pylint",
# A bit dangerous, but needed to allow pylint
# to work across versions.
"--disable=unrecognized-option",
"src",
"tests",
)
else:
session.log(f"Skipping unknown command {c}")

Expand Down Expand Up @@ -874,7 +884,7 @@ def get_package_wheel(

# save that this was called:
if reuse:
get_package_wheel._called = True # type: ignore[attr-defined] # noqa: SLF001
get_package_wheel._called = True # type: ignore[attr-defined] # noqa: SLF001 # pylint: disable=protected-access

paths = list(dist_location.glob("*.whl"))
if len(paths) != 1:
Expand Down Expand Up @@ -1051,8 +1061,6 @@ def get_target_path(

root = Path("./docs/examples/")
if clean:
import shutil

shutil.rmtree(root / "usage", ignore_errors=True)

# get all md files
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ tools = [
"scriv",
]
typing = [
"pylint",
"pytest",
"types-click",
{ include-group = "uvxrun" },
Expand Down
30 changes: 15 additions & 15 deletions requirements/lock/py312-uvxrun-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ beautifulsoup4==4.12.3 \
--hash=sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051 \
--hash=sha256:b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed
# via grayskull
cachecontrol==0.14.1 \
--hash=sha256:06ef916a1e4eb7dba9948cdfc9c76e749db2e02104a9a1277e8b642591a0f717 \
--hash=sha256:65e3abd62b06382ce3894df60dde9e0deb92aeb734724f68fa4f3b91e97206b9
cachecontrol==0.14.2 \
--hash=sha256:7d47d19f866409b98ff6025b6a0fca8e4c791fb31abbd95f622093894ce903a2 \
--hash=sha256:ebad2091bf12d0d200dfc2464330db638c5deb41d546f6d7aca079e87290f3b0
# via conda-lock
cachy==0.3.0 \
--hash=sha256:186581f4ceb42a0bbe040c407da73c14092379b1e4c0e327fdb72ae4a9b269b1 \
Expand Down Expand Up @@ -304,9 +304,9 @@ html5lib==1.1 \
--hash=sha256:0d78f8fde1c230e99fe37986a60526d7049ed4bf8a9fadbad5f00e22e58e041d \
--hash=sha256:b2e5b40261e20f354d198eae92afc10d750afb487ed5e50f9c4eaf07c184146f
# via conda-lock
identify==2.6.4 \
--hash=sha256:285a7d27e397652e8cafe537a6cc97dd470a970f48fb2e9d979aa38eae5513ac \
--hash=sha256:993b0f01b97e0568c179bb9196391ff391bfb88a99099dbf5ce392b68f42d0af
identify==2.6.5 \
--hash=sha256:14181a47091eb75b337af4c23078c9d09225cd4c48929f521f3bf16b09d02566 \
--hash=sha256:c10b33f250e5bba374fae86fb57f3adcebf1161bce7cdf92031915fd480c13bc
# via pre-commit
idna==3.10 \
--hash=sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9 \
Expand Down Expand Up @@ -729,9 +729,9 @@ pydantic-core==2.27.2 \
--hash=sha256:fa8e459d4954f608fa26116118bb67f56b93b209c39b008277ace29937453dc9 \
--hash=sha256:fd1aea04935a508f62e0d0ef1f5ae968774a32afc306fb8545e06f5ff5cdf3ad
# via pydantic
pygments==2.18.0 \
--hash=sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199 \
--hash=sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a
pygments==2.19.1 \
--hash=sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f \
--hash=sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c
# via ipython, readme-renderer, rich
pylev==1.4.0 \
--hash=sha256:7b2e2aa7b00e05bb3f7650eb506fc89f474f70493271a35c242d9a92188ad3dd \
Expand Down Expand Up @@ -918,9 +918,9 @@ rich==13.9.4 \
--hash=sha256:439594978a49a09530cff7ebc4b5c7103ef57baf48d5ea3184f21d9a2befa098 \
--hash=sha256:6049d5e6ec054bf2779ab3358186963bac2ea89175919d699e378b99738c2a90
# via twine, typer
ruamel-yaml==0.18.8 \
--hash=sha256:1b7e14f28a4b8d09f8cd40dca158852db9b22ac84f22da5bb711def35cb5c548 \
--hash=sha256:a7c02af6ec9789495b4d19335addabc4d04ab1e0dad3e491c0c9457bbc881100
ruamel-yaml==0.18.10 \
--hash=sha256:20c86ab29ac2153f80a428e1254a8adf686d3383df04490514ca3b79a362db58 \
--hash=sha256:30f22513ab2301b3d2b577adc121c6471f28734d3d9728581245f1e76468b4f1
# via conda-lock, conda-souschef, grayskull, ruamel-yaml-jinja2
ruamel-yaml-clib==0.2.12 ; python_full_version < '3.13' and platform_python_implementation == 'CPython' \
--hash=sha256:040ae85536960525ea62868b642bdb0c2cc6021c9f9d507810c0c604e66f5a7b \
Expand Down Expand Up @@ -982,9 +982,9 @@ secretstorage==3.3.3 ; sys_platform == 'linux' \
--hash=sha256:2403533ef369eca6d2ba81718576c5e0f564d5cca1b58f73a8b23e7d4eeebd77 \
--hash=sha256:f356e6628222568e3af06f2eba8df495efa13b3b63081dafd4f7d9a7b7bc9f99
# via keyring
setuptools==75.6.0 \
--hash=sha256:8199222558df7c86216af4f84c30e9b34a61d8ba19366cc914424cdbd28252f6 \
--hash=sha256:ce74b49e8f7110f9bf04883b730f4765b774ef3ef28f722cce7c273d253aaf7d
setuptools==75.7.0 \
--hash=sha256:84fb203f278ebcf5cd08f97d3fb96d3fbed4b629d500b29ad60d11e00769b183 \
--hash=sha256:886ff7b16cd342f1d1defc16fc98c9ce3fde69e087a4e1983d7ab634e5f41f4f
# via conda-lock, grayskull
shellingham==1.5.4 \
--hash=sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686 \
Expand Down
1 change: 1 addition & 0 deletions requirements/py312-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
- mypy>=1.14.1
- nox>=2024.4.15
- packaging
- pylint
- pytest
- pytest-cov
- pytest-sugar
Expand Down
Loading

0 comments on commit f9f529f

Please sign in to comment.