diff --git a/pyproject.toml b/pyproject.toml index 5408d27733..977d953627 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,71 +8,62 @@ filterwarnings = [ "ignore:^pkg_resources is deprecated as an API:DeprecationWarning:pyramid", "ignore:^Deprecated call to .pkg_resources\\.declare_namespace\\('.*'\\).\\.:DeprecationWarning:pkg_resources", "ignore:^'cgi' is deprecated and slated for removal in Python 3\\.13$:DeprecationWarning:webob", -] - -[tool.coverage.run] -branch = true -parallel = true -source = ["lms", "tests/unit"] -omit = [ - "*/lms/__main__.py", - "*/lms/scripts/init_db.py", - "lms/pshell.py", - "lms/migrations/*", - "lms/extensions/feature_flags/views/test.py", - "lms/views/feature_flags_test.py", -] - -[tool.coverage.paths] -source = ["src", ".tox/*tests/lib/python*/site-packages"] - -[tool.coverage.report] -show_missing = true -precision = 2 -fail_under = 100.00 -skip_covered = true -exclude_also = [ - # # TYPE_CHECKING block is only executed while running mypy - "if TYPE_CHECKING:" + "ignore:^datetime\\.datetime\\.utcnow\\(\\) is deprecated and scheduled for removal in a future version\\.:DeprecationWarning", ] [tool.ruff] target-version = "py311" -line-length = 88 -exclude = [ - "tests/bdd/steps/_compiled_feature_steps.py", -] [tool.ruff.lint] -select = [ - "E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w - "D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d - "ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg - "BLE001", # https://docs.astral.sh/ruff/rules/blind-except/ - "R", "PLR", # https://docs.astral.sh/ruff/rules/#refactor-r - "C", "PLC", # https://docs.astral.sh/ruff/rules/#convention-c - "SLF", # flake-8-self - "N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n - "F", # https://docs.astral.sh/ruff/rules/unused-import/ - - "RUF100", # unused-noqa -] - +select = ["ALL"] ignore = [ - # Missing docstrings. - "D100","D101","D102","D103","D104","D105","D106","D107", - - # "No blank lines allowed after function docstring" conflicts with the - # Black code formatter which insists on inserting blank lines after - # function docstrings. - "D202", - - # "1 blank line required before class docstring" conflicts with another - # pydocstyle rule D211 "No blank lines allowed before class docstring". - "D203", - - # "Multi-line docstring summary should start at the first line" - # and "Multi-line docstring summary should start at the second line". + "UP", # pyupgrade + "YTT", # flake8-2020 (checks for misuse of sys.version or sys.version_info + "ANN", # flake8-annotations (checks for absence of type annotations on functions) + "ASYNC", # flake8-async (checks for asyncio-related problems) + "S", # flake8-bandit (checks for security issues) + "FBT", # flake8-boolean-trap (checks for the "boolean trap" anti-pattern) + "B", # flake8-bugbear (checks for bugs and design problems) + "A", # flake8-builtins (checks for builtins being overridden) + "CPY", # flake8-copyright (checks for missing copyright notices) + "C4", # flake8-comprehensions (helps write better list/set/dict comprehensions) + "DTZ", # flake8-datetimez (checks for usages of unsafe naive datetime class) + "T10", # flake8-debugger (checks for set traces etc) + "EM", # flake8-errmsg (checks for error message formatting issues) + "EXE", # flake8-executable (checks for incorrect executable permissions and shebangs) + "FA", # flake8-future-annotations (checks for missing from __future__ import annotations) + "ISC", # flake8-implicit-str-concat (checks for style problems with string literal concatenation) + "ICN", # flake8-import-conventions (checks for unconventional imports and aliases) + "LOG", # flake8-logging (checks for issues with using the logging module) + "G", # flake8-logging-format (enforce usage of `extra` in logging calls) + "INP", # flake8-no-pep420 (checks for missing __init__.py files) + "PIE", # flake8-pie (miscellaneous) + "T20", # flake8-print (checks for print and pprint statements) + "PT", # flake8-pytest-style (checks for common pytest style and consistency issues) + "RSE", # flake8-raise (checks for issues with raising exceptions) + "RET", # flake8-return (checks for issues with return values) + "SLOT", # flake8-slots (requires __slots__ in subclasses of immutable types) + "SIM", # flake8-simplify (lots of code simplification checks) + "TID", # flake8-tidy-imports (checks for issues with imports) + "TC", # flake8-type-checking (checks for type checking imports that aren't in TYPE_CHECKING blocks) + "ARG", # flake8-unused-arguments (checks for unused arguments) + "PTH", # flake8-use-pathlib (checks for cases with pathlib could be used but isn't) + "TD", # flake8-todos (enforces good style for "# TODO" comments) + "FIX", # flake8-fixme (checks for FIXMEs, TODOs, HACKs, etc) + "ERA", # eradicate (checks for commented-out code) + "PGH", # pygrep-hooks (miscellaneous) + "PL", # pylint (miscellaneous rules from pylint) + "TRY", # tryceratops (various try/except-related checks) + "FLY", # flynt (checks for old-style %-formatted strings) + "PERF", # perflint (checks for performance anti-patterns) + "FURB", # refurb (various "refurbishing and modernizing" checks) + "DOC", # pydoclint (docstring checks) + "RUF", # Ruff-specific rules + "COM", # flake8-commas (we used a code formatter so we don't need a linter to check this) + "D100","D101","D102","D103","D104","D105","D106","D107", # Missing docstrings. + "D202", # "No blank lines allowed after function docstring" conflicts with the Ruff code formatter. + # "Multi-line docstring summary should start at the first line" (D212) + # and "Multi-line docstring summary should start at the second line" (D213). # These two rules conflict with each other so you have to disable one of them. # How about we disable them both? PEP 257 says either approach is okay: # @@ -80,19 +71,12 @@ ignore = [ # > the next line. # > # > https://peps.python.org/pep-0257/#multi-line-docstrings - "D212", - "D213", - - # We use Black to format our code automatically, so we don't need PyLint to - # check formatting for us. - "E501", # line-too-long - - "PLR2004", # Magic values, we mostly get it on HTTP status codes - - # Disabled during the pylint migration, ideally we'll enable this after we are settled in ruff - "RET504", - "RET501", - "PLR6301", + "D212", "D213", + "E501", # line-too-long (we use the code formatter so we don't need the linter to check line lengths for us). + "PLR2004", # "Magic value used in comparison", this mostly triggers false-positives related to HTTP status codes. + "PLR6301", # Method could be a function/classmethod/static method (doesn't use self) + "RET501", # Do not explicitly return None if it's the only possible return value. + "RET504", # Unnecessary assignment before return statement. ] [tool.ruff.lint.per-file-ignores] @@ -103,36 +87,58 @@ ignore = [ # snake_case, such as a fixture that returns a mock of the FooBar class would # be named FooBar in CamelCase. "N", - # We are more lax about comment formatting in the tests - "D", - - "PLR0913", + "PLR0913", # Too many arguments. Tests often have lots of arguments. + "PLR0917", # Too many positional arguments. Tests often have lots of arguments. + "PLR0904", # Too many public methods. Test classes often have lots of test methods. +] +"__init__.py" = [ + "F401", # Ignore unused import errors on __init__ files to avoid having to add either a noqa stament or an __all__ declaration. +] - # Lots of test methods don't use self, but we still want to group our tests - # into classes. - "PLR6301", +[tool.coverage.run] +branch = true +parallel = true +source = ["lms", "tests/unit"] +omit = [ + "*/lms/__main__.py", + "*/lms/scripts/init_db.py", + "lms/pshell.py", + "lms/migrations/*", + "lms/extensions/feature_flags/views/test.py", + "lms/views/feature_flags_test.py", +] + +[tool.coverage.paths] +source = ["src", ".tox/*tests/lib/python*/site-packages"] - "PLR0917", # too-many-arguments - "PLC2701", # private import - "PLR0904", # too-many-public-methods -] -# Ignore unused import errors on __init__ files to avoid having to add either a noqa stament or an __all__ declaration. -"__init__.py" = ["F401"] +[tool.coverage.report] +show_missing = true +precision = 2 +fail_under = 100.00 +skip_covered = true +exclude_also = [ + # `if TYPE_CHECKING:` blocks are only executed while running mypy. + "if TYPE_CHECKING:", +] [tool.mypy] -python_version = 3.11 +allow_untyped_globals = true +error_summary = false +pretty = true warn_unused_configs = true warn_redundant_casts = true warn_unused_ignores = true check_untyped_defs = true disable_error_code = [ + # https://mypy.readthedocs.io/en/stable/error_code_list.html#code-import-untyped "import-untyped", ] [[tool.mypy.overrides]] -module= [ +module = [ + # Don't try to typecheck the tests for now. "tests.*", # Migrations are often autogenerated or big blocks of SQL "lms.migrations.*",