From 1e696a7c4f35f1726bf592c92a0015730777ab0e Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Thu, 15 Aug 2024 11:25:12 -0700 Subject: [PATCH] Update the shared Ruff configuration - Exclude ASYNC109, which required adjusting the comment column - Drop the S113 exclusion, since its httpx bug was fixed - Add additional per-file exclusions useful for vertical monorepos - Drop the McCabe complexity override The exclusions for vertical monorepos unfortunately appear to require duplicating the exclusion lists, or at least I don't know a way to write a glob that matches the paths both with and without a prefix. Since they have to be duplicated, I made them exact copies so that future maintenance is an easy cut and paste. The McCabe complexity threshold increase from 10 to 11 was something I added for Gafaelfawr, but I found a better way to break apart the relevant Gafaelfawr function and other packages appear to not have trouble with a limit of 10. --- .../example-uws/ruff-shared.toml | 100 ++++++++++-------- .../example/ruff-shared.toml | 100 ++++++++++-------- .../{{cookiecutter.name}}/ruff-shared.toml | 100 ++++++++++-------- .../example/ruff-shared.toml | 100 ++++++++++-------- .../{{cookiecutter.name}}/ruff-shared.toml | 100 ++++++++++-------- .../technote_md/testn-000/technote.toml | 2 +- .../technote_rst/testn-000/technote.toml | 2 +- 7 files changed, 282 insertions(+), 222 deletions(-) diff --git a/project_templates/fastapi_safir_app/example-uws/ruff-shared.toml b/project_templates/fastapi_safir_app/example-uws/ruff-shared.toml index dc46f19b..0702eaf1 100644 --- a/project_templates/fastapi_safir_app/example-uws/ruff-shared.toml +++ b/project_templates/fastapi_safir_app/example-uws/ruff-shared.toml @@ -27,44 +27,45 @@ docstring-code-format = true [lint] ignore = [ - "ANN401", # sometimes Any is the right type - "ARG001", # unused function arguments are often legitimate - "ARG002", # unused method arguments are often legitimate - "ARG003", # unused class method arguments are often legitimate - "ARG005", # unused lambda arguments are often legitimate - "BLE001", # we want to catch and report Exception in background tasks - "C414", # nested sorted is how you sort by multiple keys with reverse - "D102", # sometimes we use docstring inheritence - "D104", # don't see the point of documenting every package - "D105", # our style doesn't require docstrings for magic methods - "D106", # Pydantic uses a nested Config class that doesn't warrant docs - "D205", # our documentation style allows a folded first line - "EM101", # justification (duplicate string in traceback) is silly - "EM102", # justification (duplicate string in traceback) is silly - "FBT003", # positional booleans are normal for Pydantic field defaults - "FIX002", # point of a TODO comment is that we're not ready to fix it - "PD011", # attempts to enforce pandas conventions for all data types - "G004", # forbidding logging f-strings is appealing, but not our style - "RET505", # disagree that omitting else always makes code more readable - "PLR0911", # often many returns is clearer and simpler style - "PLR0913", # factory pattern uses constructors with many arguments - "PLR2004", # too aggressive about magic values - "PLW0603", # yes global is discouraged but if needed, it's needed - "S105", # good idea but too many false positives on non-passwords - "S106", # good idea but too many false positives on non-passwords - "S107", # good idea but too many false positives on non-passwords - "S603", # not going to manually mark every subprocess call as reviewed - "S607", # using PATH is not a security vulnerability - "SIM102", # sometimes the formatting of nested if statements is clearer - "SIM117", # sometimes nested with contexts are clearer - "TCH001", # we decided to not maintain separate TYPE_CHECKING blocks - "TCH002", # we decided to not maintain separate TYPE_CHECKING blocks - "TCH003", # we decided to not maintain separate TYPE_CHECKING blocks - "TD003", # we don't require issues be created for TODOs - "TID252", # if we're going to use relative imports, use them always - "TRY003", # good general advice but lint is way too aggressive - "TRY301", # sometimes raising exceptions inside try is the best flow - "UP040", # PEP 695 type aliases not yet supported by mypy + "ANN401", # sometimes Any is the right type + "ARG001", # unused function arguments are often legitimate + "ARG002", # unused method arguments are often legitimate + "ARG003", # unused class method arguments are often legitimate + "ARG005", # unused lambda arguments are often legitimate + "ASYNC109", # many async functions use asyncio.timeout internally + "BLE001", # we want to catch and report Exception in background tasks + "C414", # nested sorted is how you sort by multiple keys with reverse + "D102", # sometimes we use docstring inheritence + "D104", # don't see the point of documenting every package + "D105", # our style doesn't require docstrings for magic methods + "D106", # Pydantic uses a nested Config class that doesn't warrant docs + "D205", # our documentation style allows a folded first line + "EM101", # justification (duplicate string in traceback) is silly + "EM102", # justification (duplicate string in traceback) is silly + "FBT003", # positional booleans are normal for Pydantic field defaults + "FIX002", # point of a TODO comment is that we're not ready to fix it + "PD011", # attempts to enforce pandas conventions for all data types + "G004", # forbidding logging f-strings is appealing, but not our style + "RET505", # disagree that omitting else always makes code more readable + "PLR0911", # often many returns is clearer and simpler style + "PLR0913", # factory pattern uses constructors with many arguments + "PLR2004", # too aggressive about magic values + "PLW0603", # yes global is discouraged but if needed, it's needed + "S105", # good idea but too many false positives on non-passwords + "S106", # good idea but too many false positives on non-passwords + "S107", # good idea but too many false positives on non-passwords + "S603", # not going to manually mark every subprocess call as reviewed + "S607", # using PATH is not a security vulnerability + "SIM102", # sometimes the formatting of nested if statements is clearer + "SIM117", # sometimes nested with contexts are clearer + "TCH001", # we decided to not maintain separate TYPE_CHECKING blocks + "TCH002", # we decided to not maintain separate TYPE_CHECKING blocks + "TCH003", # we decided to not maintain separate TYPE_CHECKING blocks + "TD003", # we don't require issues be created for TODOs + "TID252", # if we're going to use relative imports, use them always + "TRY003", # good general advice but lint is way too aggressive + "TRY301", # sometimes raising exceptions inside try is the best flow + "UP040", # PEP 695 type aliases not yet supported by mypy # The following settings should be disabled when using ruff format # per https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules @@ -82,16 +83,19 @@ ignore = [ "COM819", "ISC001", "ISC002", - - # Temporary bug workarounds. - "S113", # https://github.com/astral-sh/ruff/issues/12210 ] select = ["ALL"] [lint.per-file-ignores] +"noxfile.py" = [ + "T201", # print makes sense as output from nox rules +] "src/*/handlers/**" = [ "D103", # FastAPI handlers should not have docstrings ] +"*/src/*/handlers/**" = [ + "D103", # FastAPI handlers should not have docstrings +] "tests/**" = [ "C901", # tests are allowed to be complex, sometimes that's convenient "D101", # tests don't need docstrings @@ -103,6 +107,17 @@ select = ["ALL"] "S301", # allow tests for whether code can be pickled "SLF001", # tests are allowed to access private members ] +"*/tests/**" = [ + "C901", # tests are allowed to be complex, sometimes that's convenient + "D101", # tests don't need docstrings + "D103", # tests don't need docstrings + "PLR0915", # tests are allowed to be long, sometimes that's convenient + "PT012", # way too aggressive about limiting pytest.raises blocks + "S101", # tests should use assert + "S106", # tests are allowed to hard-code dummy passwords + "S301", # allow tests for whether code can be pickled + "SLF001", # tests are allowed to access private members +] # These are too useful as attributes or methods to allow the conflict with the # built-in to rule out their use. @@ -120,8 +135,5 @@ builtins-ignorelist = [ fixture-parentheses = false mark-parentheses = false -[lint.mccabe] -max-complexity = 11 - [lint.pydocstyle] convention = "numpy" diff --git a/project_templates/fastapi_safir_app/example/ruff-shared.toml b/project_templates/fastapi_safir_app/example/ruff-shared.toml index dc46f19b..0702eaf1 100644 --- a/project_templates/fastapi_safir_app/example/ruff-shared.toml +++ b/project_templates/fastapi_safir_app/example/ruff-shared.toml @@ -27,44 +27,45 @@ docstring-code-format = true [lint] ignore = [ - "ANN401", # sometimes Any is the right type - "ARG001", # unused function arguments are often legitimate - "ARG002", # unused method arguments are often legitimate - "ARG003", # unused class method arguments are often legitimate - "ARG005", # unused lambda arguments are often legitimate - "BLE001", # we want to catch and report Exception in background tasks - "C414", # nested sorted is how you sort by multiple keys with reverse - "D102", # sometimes we use docstring inheritence - "D104", # don't see the point of documenting every package - "D105", # our style doesn't require docstrings for magic methods - "D106", # Pydantic uses a nested Config class that doesn't warrant docs - "D205", # our documentation style allows a folded first line - "EM101", # justification (duplicate string in traceback) is silly - "EM102", # justification (duplicate string in traceback) is silly - "FBT003", # positional booleans are normal for Pydantic field defaults - "FIX002", # point of a TODO comment is that we're not ready to fix it - "PD011", # attempts to enforce pandas conventions for all data types - "G004", # forbidding logging f-strings is appealing, but not our style - "RET505", # disagree that omitting else always makes code more readable - "PLR0911", # often many returns is clearer and simpler style - "PLR0913", # factory pattern uses constructors with many arguments - "PLR2004", # too aggressive about magic values - "PLW0603", # yes global is discouraged but if needed, it's needed - "S105", # good idea but too many false positives on non-passwords - "S106", # good idea but too many false positives on non-passwords - "S107", # good idea but too many false positives on non-passwords - "S603", # not going to manually mark every subprocess call as reviewed - "S607", # using PATH is not a security vulnerability - "SIM102", # sometimes the formatting of nested if statements is clearer - "SIM117", # sometimes nested with contexts are clearer - "TCH001", # we decided to not maintain separate TYPE_CHECKING blocks - "TCH002", # we decided to not maintain separate TYPE_CHECKING blocks - "TCH003", # we decided to not maintain separate TYPE_CHECKING blocks - "TD003", # we don't require issues be created for TODOs - "TID252", # if we're going to use relative imports, use them always - "TRY003", # good general advice but lint is way too aggressive - "TRY301", # sometimes raising exceptions inside try is the best flow - "UP040", # PEP 695 type aliases not yet supported by mypy + "ANN401", # sometimes Any is the right type + "ARG001", # unused function arguments are often legitimate + "ARG002", # unused method arguments are often legitimate + "ARG003", # unused class method arguments are often legitimate + "ARG005", # unused lambda arguments are often legitimate + "ASYNC109", # many async functions use asyncio.timeout internally + "BLE001", # we want to catch and report Exception in background tasks + "C414", # nested sorted is how you sort by multiple keys with reverse + "D102", # sometimes we use docstring inheritence + "D104", # don't see the point of documenting every package + "D105", # our style doesn't require docstrings for magic methods + "D106", # Pydantic uses a nested Config class that doesn't warrant docs + "D205", # our documentation style allows a folded first line + "EM101", # justification (duplicate string in traceback) is silly + "EM102", # justification (duplicate string in traceback) is silly + "FBT003", # positional booleans are normal for Pydantic field defaults + "FIX002", # point of a TODO comment is that we're not ready to fix it + "PD011", # attempts to enforce pandas conventions for all data types + "G004", # forbidding logging f-strings is appealing, but not our style + "RET505", # disagree that omitting else always makes code more readable + "PLR0911", # often many returns is clearer and simpler style + "PLR0913", # factory pattern uses constructors with many arguments + "PLR2004", # too aggressive about magic values + "PLW0603", # yes global is discouraged but if needed, it's needed + "S105", # good idea but too many false positives on non-passwords + "S106", # good idea but too many false positives on non-passwords + "S107", # good idea but too many false positives on non-passwords + "S603", # not going to manually mark every subprocess call as reviewed + "S607", # using PATH is not a security vulnerability + "SIM102", # sometimes the formatting of nested if statements is clearer + "SIM117", # sometimes nested with contexts are clearer + "TCH001", # we decided to not maintain separate TYPE_CHECKING blocks + "TCH002", # we decided to not maintain separate TYPE_CHECKING blocks + "TCH003", # we decided to not maintain separate TYPE_CHECKING blocks + "TD003", # we don't require issues be created for TODOs + "TID252", # if we're going to use relative imports, use them always + "TRY003", # good general advice but lint is way too aggressive + "TRY301", # sometimes raising exceptions inside try is the best flow + "UP040", # PEP 695 type aliases not yet supported by mypy # The following settings should be disabled when using ruff format # per https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules @@ -82,16 +83,19 @@ ignore = [ "COM819", "ISC001", "ISC002", - - # Temporary bug workarounds. - "S113", # https://github.com/astral-sh/ruff/issues/12210 ] select = ["ALL"] [lint.per-file-ignores] +"noxfile.py" = [ + "T201", # print makes sense as output from nox rules +] "src/*/handlers/**" = [ "D103", # FastAPI handlers should not have docstrings ] +"*/src/*/handlers/**" = [ + "D103", # FastAPI handlers should not have docstrings +] "tests/**" = [ "C901", # tests are allowed to be complex, sometimes that's convenient "D101", # tests don't need docstrings @@ -103,6 +107,17 @@ select = ["ALL"] "S301", # allow tests for whether code can be pickled "SLF001", # tests are allowed to access private members ] +"*/tests/**" = [ + "C901", # tests are allowed to be complex, sometimes that's convenient + "D101", # tests don't need docstrings + "D103", # tests don't need docstrings + "PLR0915", # tests are allowed to be long, sometimes that's convenient + "PT012", # way too aggressive about limiting pytest.raises blocks + "S101", # tests should use assert + "S106", # tests are allowed to hard-code dummy passwords + "S301", # allow tests for whether code can be pickled + "SLF001", # tests are allowed to access private members +] # These are too useful as attributes or methods to allow the conflict with the # built-in to rule out their use. @@ -120,8 +135,5 @@ builtins-ignorelist = [ fixture-parentheses = false mark-parentheses = false -[lint.mccabe] -max-complexity = 11 - [lint.pydocstyle] convention = "numpy" diff --git a/project_templates/fastapi_safir_app/{{cookiecutter.name}}/ruff-shared.toml b/project_templates/fastapi_safir_app/{{cookiecutter.name}}/ruff-shared.toml index dc46f19b..0702eaf1 100644 --- a/project_templates/fastapi_safir_app/{{cookiecutter.name}}/ruff-shared.toml +++ b/project_templates/fastapi_safir_app/{{cookiecutter.name}}/ruff-shared.toml @@ -27,44 +27,45 @@ docstring-code-format = true [lint] ignore = [ - "ANN401", # sometimes Any is the right type - "ARG001", # unused function arguments are often legitimate - "ARG002", # unused method arguments are often legitimate - "ARG003", # unused class method arguments are often legitimate - "ARG005", # unused lambda arguments are often legitimate - "BLE001", # we want to catch and report Exception in background tasks - "C414", # nested sorted is how you sort by multiple keys with reverse - "D102", # sometimes we use docstring inheritence - "D104", # don't see the point of documenting every package - "D105", # our style doesn't require docstrings for magic methods - "D106", # Pydantic uses a nested Config class that doesn't warrant docs - "D205", # our documentation style allows a folded first line - "EM101", # justification (duplicate string in traceback) is silly - "EM102", # justification (duplicate string in traceback) is silly - "FBT003", # positional booleans are normal for Pydantic field defaults - "FIX002", # point of a TODO comment is that we're not ready to fix it - "PD011", # attempts to enforce pandas conventions for all data types - "G004", # forbidding logging f-strings is appealing, but not our style - "RET505", # disagree that omitting else always makes code more readable - "PLR0911", # often many returns is clearer and simpler style - "PLR0913", # factory pattern uses constructors with many arguments - "PLR2004", # too aggressive about magic values - "PLW0603", # yes global is discouraged but if needed, it's needed - "S105", # good idea but too many false positives on non-passwords - "S106", # good idea but too many false positives on non-passwords - "S107", # good idea but too many false positives on non-passwords - "S603", # not going to manually mark every subprocess call as reviewed - "S607", # using PATH is not a security vulnerability - "SIM102", # sometimes the formatting of nested if statements is clearer - "SIM117", # sometimes nested with contexts are clearer - "TCH001", # we decided to not maintain separate TYPE_CHECKING blocks - "TCH002", # we decided to not maintain separate TYPE_CHECKING blocks - "TCH003", # we decided to not maintain separate TYPE_CHECKING blocks - "TD003", # we don't require issues be created for TODOs - "TID252", # if we're going to use relative imports, use them always - "TRY003", # good general advice but lint is way too aggressive - "TRY301", # sometimes raising exceptions inside try is the best flow - "UP040", # PEP 695 type aliases not yet supported by mypy + "ANN401", # sometimes Any is the right type + "ARG001", # unused function arguments are often legitimate + "ARG002", # unused method arguments are often legitimate + "ARG003", # unused class method arguments are often legitimate + "ARG005", # unused lambda arguments are often legitimate + "ASYNC109", # many async functions use asyncio.timeout internally + "BLE001", # we want to catch and report Exception in background tasks + "C414", # nested sorted is how you sort by multiple keys with reverse + "D102", # sometimes we use docstring inheritence + "D104", # don't see the point of documenting every package + "D105", # our style doesn't require docstrings for magic methods + "D106", # Pydantic uses a nested Config class that doesn't warrant docs + "D205", # our documentation style allows a folded first line + "EM101", # justification (duplicate string in traceback) is silly + "EM102", # justification (duplicate string in traceback) is silly + "FBT003", # positional booleans are normal for Pydantic field defaults + "FIX002", # point of a TODO comment is that we're not ready to fix it + "PD011", # attempts to enforce pandas conventions for all data types + "G004", # forbidding logging f-strings is appealing, but not our style + "RET505", # disagree that omitting else always makes code more readable + "PLR0911", # often many returns is clearer and simpler style + "PLR0913", # factory pattern uses constructors with many arguments + "PLR2004", # too aggressive about magic values + "PLW0603", # yes global is discouraged but if needed, it's needed + "S105", # good idea but too many false positives on non-passwords + "S106", # good idea but too many false positives on non-passwords + "S107", # good idea but too many false positives on non-passwords + "S603", # not going to manually mark every subprocess call as reviewed + "S607", # using PATH is not a security vulnerability + "SIM102", # sometimes the formatting of nested if statements is clearer + "SIM117", # sometimes nested with contexts are clearer + "TCH001", # we decided to not maintain separate TYPE_CHECKING blocks + "TCH002", # we decided to not maintain separate TYPE_CHECKING blocks + "TCH003", # we decided to not maintain separate TYPE_CHECKING blocks + "TD003", # we don't require issues be created for TODOs + "TID252", # if we're going to use relative imports, use them always + "TRY003", # good general advice but lint is way too aggressive + "TRY301", # sometimes raising exceptions inside try is the best flow + "UP040", # PEP 695 type aliases not yet supported by mypy # The following settings should be disabled when using ruff format # per https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules @@ -82,16 +83,19 @@ ignore = [ "COM819", "ISC001", "ISC002", - - # Temporary bug workarounds. - "S113", # https://github.com/astral-sh/ruff/issues/12210 ] select = ["ALL"] [lint.per-file-ignores] +"noxfile.py" = [ + "T201", # print makes sense as output from nox rules +] "src/*/handlers/**" = [ "D103", # FastAPI handlers should not have docstrings ] +"*/src/*/handlers/**" = [ + "D103", # FastAPI handlers should not have docstrings +] "tests/**" = [ "C901", # tests are allowed to be complex, sometimes that's convenient "D101", # tests don't need docstrings @@ -103,6 +107,17 @@ select = ["ALL"] "S301", # allow tests for whether code can be pickled "SLF001", # tests are allowed to access private members ] +"*/tests/**" = [ + "C901", # tests are allowed to be complex, sometimes that's convenient + "D101", # tests don't need docstrings + "D103", # tests don't need docstrings + "PLR0915", # tests are allowed to be long, sometimes that's convenient + "PT012", # way too aggressive about limiting pytest.raises blocks + "S101", # tests should use assert + "S106", # tests are allowed to hard-code dummy passwords + "S301", # allow tests for whether code can be pickled + "SLF001", # tests are allowed to access private members +] # These are too useful as attributes or methods to allow the conflict with the # built-in to rule out their use. @@ -120,8 +135,5 @@ builtins-ignorelist = [ fixture-parentheses = false mark-parentheses = false -[lint.mccabe] -max-complexity = 11 - [lint.pydocstyle] convention = "numpy" diff --git a/project_templates/square_pypi_package/example/ruff-shared.toml b/project_templates/square_pypi_package/example/ruff-shared.toml index dc46f19b..0702eaf1 100644 --- a/project_templates/square_pypi_package/example/ruff-shared.toml +++ b/project_templates/square_pypi_package/example/ruff-shared.toml @@ -27,44 +27,45 @@ docstring-code-format = true [lint] ignore = [ - "ANN401", # sometimes Any is the right type - "ARG001", # unused function arguments are often legitimate - "ARG002", # unused method arguments are often legitimate - "ARG003", # unused class method arguments are often legitimate - "ARG005", # unused lambda arguments are often legitimate - "BLE001", # we want to catch and report Exception in background tasks - "C414", # nested sorted is how you sort by multiple keys with reverse - "D102", # sometimes we use docstring inheritence - "D104", # don't see the point of documenting every package - "D105", # our style doesn't require docstrings for magic methods - "D106", # Pydantic uses a nested Config class that doesn't warrant docs - "D205", # our documentation style allows a folded first line - "EM101", # justification (duplicate string in traceback) is silly - "EM102", # justification (duplicate string in traceback) is silly - "FBT003", # positional booleans are normal for Pydantic field defaults - "FIX002", # point of a TODO comment is that we're not ready to fix it - "PD011", # attempts to enforce pandas conventions for all data types - "G004", # forbidding logging f-strings is appealing, but not our style - "RET505", # disagree that omitting else always makes code more readable - "PLR0911", # often many returns is clearer and simpler style - "PLR0913", # factory pattern uses constructors with many arguments - "PLR2004", # too aggressive about magic values - "PLW0603", # yes global is discouraged but if needed, it's needed - "S105", # good idea but too many false positives on non-passwords - "S106", # good idea but too many false positives on non-passwords - "S107", # good idea but too many false positives on non-passwords - "S603", # not going to manually mark every subprocess call as reviewed - "S607", # using PATH is not a security vulnerability - "SIM102", # sometimes the formatting of nested if statements is clearer - "SIM117", # sometimes nested with contexts are clearer - "TCH001", # we decided to not maintain separate TYPE_CHECKING blocks - "TCH002", # we decided to not maintain separate TYPE_CHECKING blocks - "TCH003", # we decided to not maintain separate TYPE_CHECKING blocks - "TD003", # we don't require issues be created for TODOs - "TID252", # if we're going to use relative imports, use them always - "TRY003", # good general advice but lint is way too aggressive - "TRY301", # sometimes raising exceptions inside try is the best flow - "UP040", # PEP 695 type aliases not yet supported by mypy + "ANN401", # sometimes Any is the right type + "ARG001", # unused function arguments are often legitimate + "ARG002", # unused method arguments are often legitimate + "ARG003", # unused class method arguments are often legitimate + "ARG005", # unused lambda arguments are often legitimate + "ASYNC109", # many async functions use asyncio.timeout internally + "BLE001", # we want to catch and report Exception in background tasks + "C414", # nested sorted is how you sort by multiple keys with reverse + "D102", # sometimes we use docstring inheritence + "D104", # don't see the point of documenting every package + "D105", # our style doesn't require docstrings for magic methods + "D106", # Pydantic uses a nested Config class that doesn't warrant docs + "D205", # our documentation style allows a folded first line + "EM101", # justification (duplicate string in traceback) is silly + "EM102", # justification (duplicate string in traceback) is silly + "FBT003", # positional booleans are normal for Pydantic field defaults + "FIX002", # point of a TODO comment is that we're not ready to fix it + "PD011", # attempts to enforce pandas conventions for all data types + "G004", # forbidding logging f-strings is appealing, but not our style + "RET505", # disagree that omitting else always makes code more readable + "PLR0911", # often many returns is clearer and simpler style + "PLR0913", # factory pattern uses constructors with many arguments + "PLR2004", # too aggressive about magic values + "PLW0603", # yes global is discouraged but if needed, it's needed + "S105", # good idea but too many false positives on non-passwords + "S106", # good idea but too many false positives on non-passwords + "S107", # good idea but too many false positives on non-passwords + "S603", # not going to manually mark every subprocess call as reviewed + "S607", # using PATH is not a security vulnerability + "SIM102", # sometimes the formatting of nested if statements is clearer + "SIM117", # sometimes nested with contexts are clearer + "TCH001", # we decided to not maintain separate TYPE_CHECKING blocks + "TCH002", # we decided to not maintain separate TYPE_CHECKING blocks + "TCH003", # we decided to not maintain separate TYPE_CHECKING blocks + "TD003", # we don't require issues be created for TODOs + "TID252", # if we're going to use relative imports, use them always + "TRY003", # good general advice but lint is way too aggressive + "TRY301", # sometimes raising exceptions inside try is the best flow + "UP040", # PEP 695 type aliases not yet supported by mypy # The following settings should be disabled when using ruff format # per https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules @@ -82,16 +83,19 @@ ignore = [ "COM819", "ISC001", "ISC002", - - # Temporary bug workarounds. - "S113", # https://github.com/astral-sh/ruff/issues/12210 ] select = ["ALL"] [lint.per-file-ignores] +"noxfile.py" = [ + "T201", # print makes sense as output from nox rules +] "src/*/handlers/**" = [ "D103", # FastAPI handlers should not have docstrings ] +"*/src/*/handlers/**" = [ + "D103", # FastAPI handlers should not have docstrings +] "tests/**" = [ "C901", # tests are allowed to be complex, sometimes that's convenient "D101", # tests don't need docstrings @@ -103,6 +107,17 @@ select = ["ALL"] "S301", # allow tests for whether code can be pickled "SLF001", # tests are allowed to access private members ] +"*/tests/**" = [ + "C901", # tests are allowed to be complex, sometimes that's convenient + "D101", # tests don't need docstrings + "D103", # tests don't need docstrings + "PLR0915", # tests are allowed to be long, sometimes that's convenient + "PT012", # way too aggressive about limiting pytest.raises blocks + "S101", # tests should use assert + "S106", # tests are allowed to hard-code dummy passwords + "S301", # allow tests for whether code can be pickled + "SLF001", # tests are allowed to access private members +] # These are too useful as attributes or methods to allow the conflict with the # built-in to rule out their use. @@ -120,8 +135,5 @@ builtins-ignorelist = [ fixture-parentheses = false mark-parentheses = false -[lint.mccabe] -max-complexity = 11 - [lint.pydocstyle] convention = "numpy" diff --git a/project_templates/square_pypi_package/{{cookiecutter.name}}/ruff-shared.toml b/project_templates/square_pypi_package/{{cookiecutter.name}}/ruff-shared.toml index dc46f19b..0702eaf1 100644 --- a/project_templates/square_pypi_package/{{cookiecutter.name}}/ruff-shared.toml +++ b/project_templates/square_pypi_package/{{cookiecutter.name}}/ruff-shared.toml @@ -27,44 +27,45 @@ docstring-code-format = true [lint] ignore = [ - "ANN401", # sometimes Any is the right type - "ARG001", # unused function arguments are often legitimate - "ARG002", # unused method arguments are often legitimate - "ARG003", # unused class method arguments are often legitimate - "ARG005", # unused lambda arguments are often legitimate - "BLE001", # we want to catch and report Exception in background tasks - "C414", # nested sorted is how you sort by multiple keys with reverse - "D102", # sometimes we use docstring inheritence - "D104", # don't see the point of documenting every package - "D105", # our style doesn't require docstrings for magic methods - "D106", # Pydantic uses a nested Config class that doesn't warrant docs - "D205", # our documentation style allows a folded first line - "EM101", # justification (duplicate string in traceback) is silly - "EM102", # justification (duplicate string in traceback) is silly - "FBT003", # positional booleans are normal for Pydantic field defaults - "FIX002", # point of a TODO comment is that we're not ready to fix it - "PD011", # attempts to enforce pandas conventions for all data types - "G004", # forbidding logging f-strings is appealing, but not our style - "RET505", # disagree that omitting else always makes code more readable - "PLR0911", # often many returns is clearer and simpler style - "PLR0913", # factory pattern uses constructors with many arguments - "PLR2004", # too aggressive about magic values - "PLW0603", # yes global is discouraged but if needed, it's needed - "S105", # good idea but too many false positives on non-passwords - "S106", # good idea but too many false positives on non-passwords - "S107", # good idea but too many false positives on non-passwords - "S603", # not going to manually mark every subprocess call as reviewed - "S607", # using PATH is not a security vulnerability - "SIM102", # sometimes the formatting of nested if statements is clearer - "SIM117", # sometimes nested with contexts are clearer - "TCH001", # we decided to not maintain separate TYPE_CHECKING blocks - "TCH002", # we decided to not maintain separate TYPE_CHECKING blocks - "TCH003", # we decided to not maintain separate TYPE_CHECKING blocks - "TD003", # we don't require issues be created for TODOs - "TID252", # if we're going to use relative imports, use them always - "TRY003", # good general advice but lint is way too aggressive - "TRY301", # sometimes raising exceptions inside try is the best flow - "UP040", # PEP 695 type aliases not yet supported by mypy + "ANN401", # sometimes Any is the right type + "ARG001", # unused function arguments are often legitimate + "ARG002", # unused method arguments are often legitimate + "ARG003", # unused class method arguments are often legitimate + "ARG005", # unused lambda arguments are often legitimate + "ASYNC109", # many async functions use asyncio.timeout internally + "BLE001", # we want to catch and report Exception in background tasks + "C414", # nested sorted is how you sort by multiple keys with reverse + "D102", # sometimes we use docstring inheritence + "D104", # don't see the point of documenting every package + "D105", # our style doesn't require docstrings for magic methods + "D106", # Pydantic uses a nested Config class that doesn't warrant docs + "D205", # our documentation style allows a folded first line + "EM101", # justification (duplicate string in traceback) is silly + "EM102", # justification (duplicate string in traceback) is silly + "FBT003", # positional booleans are normal for Pydantic field defaults + "FIX002", # point of a TODO comment is that we're not ready to fix it + "PD011", # attempts to enforce pandas conventions for all data types + "G004", # forbidding logging f-strings is appealing, but not our style + "RET505", # disagree that omitting else always makes code more readable + "PLR0911", # often many returns is clearer and simpler style + "PLR0913", # factory pattern uses constructors with many arguments + "PLR2004", # too aggressive about magic values + "PLW0603", # yes global is discouraged but if needed, it's needed + "S105", # good idea but too many false positives on non-passwords + "S106", # good idea but too many false positives on non-passwords + "S107", # good idea but too many false positives on non-passwords + "S603", # not going to manually mark every subprocess call as reviewed + "S607", # using PATH is not a security vulnerability + "SIM102", # sometimes the formatting of nested if statements is clearer + "SIM117", # sometimes nested with contexts are clearer + "TCH001", # we decided to not maintain separate TYPE_CHECKING blocks + "TCH002", # we decided to not maintain separate TYPE_CHECKING blocks + "TCH003", # we decided to not maintain separate TYPE_CHECKING blocks + "TD003", # we don't require issues be created for TODOs + "TID252", # if we're going to use relative imports, use them always + "TRY003", # good general advice but lint is way too aggressive + "TRY301", # sometimes raising exceptions inside try is the best flow + "UP040", # PEP 695 type aliases not yet supported by mypy # The following settings should be disabled when using ruff format # per https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules @@ -82,16 +83,19 @@ ignore = [ "COM819", "ISC001", "ISC002", - - # Temporary bug workarounds. - "S113", # https://github.com/astral-sh/ruff/issues/12210 ] select = ["ALL"] [lint.per-file-ignores] +"noxfile.py" = [ + "T201", # print makes sense as output from nox rules +] "src/*/handlers/**" = [ "D103", # FastAPI handlers should not have docstrings ] +"*/src/*/handlers/**" = [ + "D103", # FastAPI handlers should not have docstrings +] "tests/**" = [ "C901", # tests are allowed to be complex, sometimes that's convenient "D101", # tests don't need docstrings @@ -103,6 +107,17 @@ select = ["ALL"] "S301", # allow tests for whether code can be pickled "SLF001", # tests are allowed to access private members ] +"*/tests/**" = [ + "C901", # tests are allowed to be complex, sometimes that's convenient + "D101", # tests don't need docstrings + "D103", # tests don't need docstrings + "PLR0915", # tests are allowed to be long, sometimes that's convenient + "PT012", # way too aggressive about limiting pytest.raises blocks + "S101", # tests should use assert + "S106", # tests are allowed to hard-code dummy passwords + "S301", # allow tests for whether code can be pickled + "SLF001", # tests are allowed to access private members +] # These are too useful as attributes or methods to allow the conflict with the # built-in to rule out their use. @@ -120,8 +135,5 @@ builtins-ignorelist = [ fixture-parentheses = false mark-parentheses = false -[lint.mccabe] -max-complexity = 11 - [lint.pydocstyle] convention = "numpy" diff --git a/project_templates/technote_md/testn-000/technote.toml b/project_templates/technote_md/testn-000/technote.toml index 6407b1a6..1a6415d7 100644 --- a/project_templates/technote_md/testn-000/technote.toml +++ b/project_templates/technote_md/testn-000/technote.toml @@ -4,7 +4,7 @@ series_id = "TESTN" canonical_url = "https://testn-000.lsst.io" github_url = "https://github.com/lsst/testn-000" github_default_branch = "main" -date_created = 2024-08-13T21:09:45Z +date_created = 2024-08-15T18:24:54Z organization.name = "Vera C. Rubin Observatory" organization.ror = "https://ror.org/048g3cy84" license.id = "CC-BY-4.0" diff --git a/project_templates/technote_rst/testn-000/technote.toml b/project_templates/technote_rst/testn-000/technote.toml index 47b54b08..dc32b056 100644 --- a/project_templates/technote_rst/testn-000/technote.toml +++ b/project_templates/technote_rst/testn-000/technote.toml @@ -4,7 +4,7 @@ series_id = "TESTN" canonical_url = "https://testn-000.lsst.io" github_url = "https://github.com/lsst/testn-000" github_default_branch = "main" -date_created = 2024-08-13T21:09:45Z +date_created = 2024-08-15T18:24:54Z organization.name = "Vera C. Rubin Observatory" organization.ror = "https://ror.org/048g3cy84" license.id = "CC-BY-4.0"