diff --git a/noxfile.py b/noxfile.py index d53e259..de9f0ff 100644 --- a/noxfile.py +++ b/noxfile.py @@ -47,7 +47,7 @@ def tests(session: nox.Session) -> None: @nox_uv.session(uv_groups=["dev"]) -def typecheck(session) -> None: +def typecheck(session: nox.Session) -> None: """Perform static type checking with ty.""" session.install(".") session.run("ty", "check", *session.posargs or ["--fix"]) diff --git a/pyproject.toml b/pyproject.toml index f53e0bc..271c05e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,6 +52,226 @@ zizmor = [ "zizmor>=1.29", ] +[tool.ruff] +target-version = "py312" +namespace-packages = [ ".github/workflows", "docs" ] +extend-exclude = [ + ".code", + ".idea", + "__pycache__", +] +show-fixes = true +# output-format = "grouped" +format.line-ending = "lf" +format.docstring-code-format = true +# Using an IDE like PyCharm with a ruff plugin will make rule names appear as inlay hints +lint.extend-select = [ + "A", + "ANN", + "ARG", + "ASYNC", + "B", + "BLE", + "C4", + "C90", + "COM", + "D", + "DOC", # in preview and not enabled as of August 2026 + "DTZ", + "E", + "EM", + "EXE", + "F", + "FA", + "FBT", + "FIX", + "FLY", + "FURB", + "G", + "I", + "ICN", + "INP", + "INT", + "ISC", + "LOG", + "N", + "NPY", + "PD", + "PERF", + "PGH", + "PIE", + "PLC", + "PLE", + "PLR", + "PLW", + "PT", + "PTH", + "PYI", + "Q", + "RET", + "RSE", + "RUF001", + "RUF002", + "RUF003", + "RUF005", + "RUF006", + "RUF007", + "RUF008", + "RUF009", + "RUF010", + "RUF012", + "RUF013", + "RUF015", + "RUF016", + "RUF017", + "RUF018", + "RUF019", + "RUF020", + "RUF021", + "RUF022", + "RUF023", + "RUF024", + "RUF026", + "RUF028", + "RUF030", + "RUF032", + "RUF033", + "RUF034", + "RUF036", + "RUF037", + "RUF040", + "RUF041", + "RUF043", + "RUF046", + "RUF048", + "RUF049", + "RUF051", + "RUF053", + "RUF057", + "RUF058", + "RUF059", + "RUF060", + "RUF061", + "RUF063", + "RUF064", + "RUF068", + "RUF100", + "RUF101", + "RUF102", + "RUF103", + "RUF104", + "RUF200", + "S", + "SIM", + "SLF", + "SLOT", + "T10", + "T20", + "TC", + "TD", + "TID", + "TRY", + "UP", + "W", + "YTT", +] +lint.ignore = [ + "COM812", # handled by ruff format + "COM819", # adding trailing commas leads to simpler diffs + "D200", # incompatible with multiline short summaries + "D203", # handled by ruff format + "D205", # incompatible with multiline short summaries + "D206", # handled by ruff format + "D300", # handled by ruff format + "E111", # handled by ruff format + "E114", # handled by ruff format + "E117", # handled by ruff format + "E501", # handled by ruff format + "PLC2401", # flags variables used as mathematical symbols + "PLC2403", # flags variables used as mathematical symbols + "Q001", # handled by ruff format + "Q002", # handled by ruff format + "Q003", # handled by ruff format + "Q004", # handled by ruff format + "W191", # handled by ruff format +] +lint.extend-per-file-ignores."__init__.py" = [ "D104", "E402", "F401", "F402", "F403" ] # ignore import errors +lint.extend-per-file-ignores."docs/conf.py" = [ "D100", "D103", "E402", "EXE001", "EXE005", "F401" ] +lint.extend-per-file-ignores."tests/**/__init__.py" = [ "D104" ] +lint.extend-per-file-ignores."tests/**/test_*.py" = [ + "DOC201", + "DOC501", + "INP001", + "PLC2701", + "S101", + "SLF001", +] +# Allow potentially ambiguous Unicode characters with valid uses in plasma science +lint.allowed-confusables = [ + "×", + "–", + "′", + "∨", + "∪", + "∼", + "⊤", + "α", + "ℂ", + "ℰ", + "ℱ", + "γ", + "ℎ", + "ι", + "ℐ", + "ℑ", + "ℒ", + "ℓ", + "ℳ", + "ν", + "ℕ", + "ο", + "𝒪", + "ℚ", + "ρ", + "ℜ", + "ℝ", + "σ", + "τ", + "β", + "υ", + "ℤ", +] +lint.flake8-import-conventions.aliases."astropy.constants" = "const" +lint.flake8-import-conventions.aliases."astropy.units" = "u" +lint.flake8-import-conventions.aliases."matplotlib.pyplot" = "plt" +lint.flake8-import-conventions.aliases.matplotlib = "mpl" +lint.flake8-import-conventions.aliases.numpy = "np" +lint.flake8-import-conventions.aliases.pandas = "pd" +lint.flake8-import-conventions.banned-from = [ + "astropy.units", + "matplotlib.pyplot", + "numpy", + "pytest", + "warnings", +] +lint.flake8-tidy-imports.ban-relative-imports = "all" +lint.flake8-tidy-imports.banned-api."typing.Callable".msg = "Deprecated alias. Change to collections.abc.Callable" +lint.flake8-tidy-imports.banned-api."typing.Collection".msg = "Deprecated alias. Change to collections.abc.Collection" +lint.flake8-tidy-imports.banned-api."typing.DefaultDict".msg = "Deprecated alias. Change to collections.defaultdict" +lint.flake8-tidy-imports.banned-api."typing.Dict".msg = "Deprecated alias. Change to dict" +lint.flake8-tidy-imports.banned-api."typing.Generator".msg = "Deprecated alias. Change to collections.abc.Generator" +lint.flake8-tidy-imports.banned-api."typing.Iterable".msg = "Deprecated alias. Change to collections.abc.Iterable" +lint.flake8-tidy-imports.banned-api."typing.Iterator".msg = "Deprecated alias. Change to collections.abc.Iterator" +lint.flake8-tidy-imports.banned-api."typing.List".msg = "Deprecated alias. Change to list" +lint.flake8-tidy-imports.banned-api."typing.Mapping".msg = "Deprecated alias. Change to collections.abc.mapping" +lint.flake8-tidy-imports.banned-api."typing.MutableMapping".msg = "Deprecated alias. Change to collections.abc.MutableMapping" +lint.flake8-tidy-imports.banned-api."typing.Sequence".msg = "Deprecated alias. Change to collections.abc.Sequence" +lint.flake8-tidy-imports.banned-api."typing.Set".msg = "Deprecated alias. Change to set" +lint.flake8-tidy-imports.banned-api."typing.Tuple".msg = "Deprecated alias. Change to tuple" +lint.flake8-tidy-imports.banned-api."typing.Type".msg = "Deprecated alias. Change to type" +lint.isort.known-first-party = [ "pyfaradaycup" ] +lint.pydocstyle.convention = "numpy" + [tool.pytest] # https://docs.pytest.org/en/stable/reference/customize.html#pyproject-toml addopts = [ "--dist=loadfile", diff --git a/src/pyfaradaycup/__init__.py b/src/pyfaradaycup/__init__.py index cc4c886..188e0be 100644 --- a/src/pyfaradaycup/__init__.py +++ b/src/pyfaradaycup/__init__.py @@ -6,5 +6,4 @@ def hello() -> str: >>> 6 * 9 54 """ - return "Hello from pyfaradaycup!" diff --git a/tests/test_placeholder.py b/tests/test_placeholder.py index 1212a97..d78dfdc 100644 --- a/tests/test_placeholder.py +++ b/tests/test_placeholder.py @@ -1,5 +1,9 @@ """Placeholder tests that shouldst be deleted after actual tests are added.""" -def test_placeholder(): - assert 42 != 6 * 9 +def test_placeholder() -> None: + """ + Test the question to the ultimate answer of meaning of life, the + universe, and everything. + """ + assert 42 != 6 * 9 # ruff:ignore[PLR2004]