2024-04-25 17:46:34 +00:00
|
|
|
[tool.poetry]
|
|
|
|
name = "python-project"
|
|
|
|
version = "0.1.0"
|
|
|
|
description = ""
|
|
|
|
authors = ["ItsDrike <itsdrike@protonmail.com>"]
|
|
|
|
readme = "README.md"
|
2024-06-28 14:18:15 +00:00
|
|
|
license = "GPL-3.0-or-later"
|
2024-04-25 17:46:34 +00:00
|
|
|
packages = [{ include = "src" }]
|
|
|
|
|
|
|
|
[tool.poetry.dependencies]
|
|
|
|
python = "^3.11"
|
2024-06-30 20:52:27 +00:00
|
|
|
typing-extensions = "^4.12.2"
|
2024-04-25 17:46:34 +00:00
|
|
|
|
|
|
|
[tool.poetry.group.dev.dependencies]
|
|
|
|
poethepoet = "^0.25.0"
|
|
|
|
|
|
|
|
[tool.poetry.group.lint.dependencies]
|
|
|
|
ruff = "^0.3.2"
|
|
|
|
pre-commit = "^3.6.2"
|
2024-07-10 15:30:22 +00:00
|
|
|
basedpyright = "^1.13.3"
|
2024-04-25 17:46:34 +00:00
|
|
|
|
|
|
|
[tool.poetry.group.test.dependencies]
|
|
|
|
pytest = "^8.1.1"
|
|
|
|
pytest-asyncio = "^0.23.6"
|
|
|
|
pytest-cov = "^5.0.0"
|
|
|
|
pytest-httpx = "^0.30.0"
|
|
|
|
|
|
|
|
[build-system]
|
|
|
|
requires = ["poetry-core"]
|
|
|
|
build-backend = "poetry.core.masonry.api"
|
|
|
|
|
|
|
|
[tool.ruff]
|
|
|
|
target-version = "py311"
|
|
|
|
line-length = 119
|
|
|
|
|
|
|
|
[tool.ruff.lint]
|
2024-06-28 14:18:15 +00:00
|
|
|
select = ["ALL"]
|
2024-04-25 17:46:34 +00:00
|
|
|
|
|
|
|
ignore = [
|
2024-06-28 14:18:15 +00:00
|
|
|
"C90", # mccabe
|
|
|
|
"FBT", # flake8-boolean-trap
|
|
|
|
"CPY", # flake8-copyright
|
|
|
|
"EM", # flake8-errmsg
|
|
|
|
"SLF", # flake8-self
|
|
|
|
"ARG", # flake8-unused-arguments
|
|
|
|
"TD", # flake8-todos
|
|
|
|
"FIX", # flake8-fixme
|
|
|
|
|
2024-04-25 17:46:34 +00:00
|
|
|
"D100", # Missing docstring in public module
|
|
|
|
"D104", # Missing docstring in public package
|
|
|
|
"D105", # Missing docstring in magic method
|
|
|
|
"D106", # Missing docstring in public nested class
|
|
|
|
"D107", # Missing docstring in __init__
|
|
|
|
"D203", # Blank line required before class docstring
|
|
|
|
"D212", # Multi-line summary should start at first line (incompatible with D211)
|
|
|
|
"D301", # Use r""" if any backslashes in a docstring
|
|
|
|
"D401", # First line of docstring should be in imperative mood
|
|
|
|
"D404", # First word of the docstring should not be "This"
|
|
|
|
"D405", # Section name should be properly capitalized
|
|
|
|
"D406", # Section name should end with a newline
|
|
|
|
"D407", # Missing dashed underline after section
|
|
|
|
"D408", # Section underline should be in the line following the section's name
|
|
|
|
"D409", # Section underline should match the length of its name
|
|
|
|
"D410", # Missing blank line after section
|
|
|
|
"D411", # Missing blank line before section
|
|
|
|
"D412", # No blank lines allowed between a section header and its content
|
|
|
|
"D413", # Missing blank line after last section
|
|
|
|
"D414", # Section has no content
|
|
|
|
"D416", # Section name should end with a colon
|
2024-07-13 11:08:49 +00:00
|
|
|
"D417", # Missing argument description in the docstring
|
2024-04-25 17:46:34 +00:00
|
|
|
|
|
|
|
"ANN101", # Missing type annotation for self in method
|
|
|
|
"ANN102", # Missing type annotation for cls in classmethod
|
|
|
|
"ANN204", # Missing return type annotation for special method
|
|
|
|
"ANN401", # Dynamically typed expressions (typing.Any) disallowed
|
|
|
|
|
|
|
|
"SIM102", # use a single if statement instead of nested if statements
|
|
|
|
"SIM108", # Use ternary operator {contents} instead of if-else-block
|
|
|
|
|
|
|
|
"B904", # Raise without `from` within an `except` clause
|
|
|
|
|
|
|
|
"PLR2004", # Using unnamed numerical constants
|
|
|
|
"PGH003", # Using specific rule codes in type ignores
|
|
|
|
"E731", # Don't asign a lambda expression, use a def
|
|
|
|
"S311", # Use `secrets` for random number generation, not `random`
|
2024-06-30 20:49:13 +00:00
|
|
|
"TRY003", # Avoid specifying long messages outside the exception class
|
2024-04-25 17:46:34 +00:00
|
|
|
|
|
|
|
# Redundant rules with ruff-format:
|
|
|
|
"E111", # Indentation of a non-multiple of 4 spaces
|
|
|
|
"E114", # Comment with indentation of a non-multiple of 4 spaces
|
|
|
|
"E117", # Cheks for over-indented code
|
|
|
|
"D206", # Checks for docstrings indented with tabs
|
|
|
|
"D300", # Checks for docstring that use ''' instead of """
|
|
|
|
"Q000", # Checks of inline strings that use wrong quotes (' instead of ")
|
|
|
|
"Q001", # Multiline string that use wrong quotes (''' instead of """)
|
|
|
|
"Q002", # Checks for docstrings that use wrong quotes (''' instead of """)
|
|
|
|
"Q003", # Checks for avoidable escaped quotes ("\"" -> '"')
|
|
|
|
"COM812", # Missing trailing comma (in multi-line lists/tuples/...)
|
|
|
|
"COM819", # Prohibited trailing comma (in single-line lists/tuples/...)
|
|
|
|
"ISC001", # Single line implicit string concatenation ("hi" "hey" -> "hihey")
|
|
|
|
"ISC002", # Multi line implicit string concatenation
|
|
|
|
]
|
|
|
|
|
|
|
|
[tool.ruff.lint.isort]
|
|
|
|
order-by-type = false
|
|
|
|
case-sensitive = true
|
|
|
|
combine-as-imports = true
|
|
|
|
|
|
|
|
# Redundant rules with ruff-format
|
|
|
|
force-single-line = false # forces all imports to appear on their own line
|
|
|
|
force-wrap-aliases = false # Split imports with multiple members and at least one alias
|
|
|
|
lines-after-imports = -1 # The number of blank lines to place after imports
|
|
|
|
lines-between-types = 0 # Number of lines to place between "direct" and import from imports
|
|
|
|
split-on-trailing-comma = false # if last member of multiline import has a comma, don't fold it to single line
|
|
|
|
|
|
|
|
[tool.ruff.lint.pylint]
|
|
|
|
max-args = 20
|
|
|
|
max-branches = 20
|
|
|
|
max-returns = 20
|
|
|
|
max-statements = 250
|
|
|
|
|
|
|
|
[tool.ruff.lint.per-file-ignores]
|
|
|
|
"tests/**.py" = [
|
|
|
|
"ANN", # annotations
|
|
|
|
"D", # docstrings
|
|
|
|
"S101", # Use of assert
|
|
|
|
]
|
|
|
|
|
|
|
|
[tool.ruff.format]
|
|
|
|
line-ending = "lf"
|
|
|
|
|
Move to a much stricter pyright configuration
This moves us from using the "standard" type-checking mode (which has a
lot of the diagnostic rules disabled, which meant we were almost in a
whitelist-based system, where most diagnostic rules were disabled unless
explicitly enabled) to "all" (where all diagnotic rules are enabled,
except for those explicitly disabled, moving us to a blacklist-based
system).
The current configuration here is very strict and might not fit all
code-bases, but it will work very well for new projects, as this
strictness, while slightly annoying sometimes, forces a lot better and
more correct typing to the previous set of rules.
This template still leaves the rules for reporting unknown types
disabled, as these are incredibly strict and while they can definitely
be beneficial, for most people it's too big of an annoyance for what
it's worth.
2024-07-13 11:01:45 +00:00
|
|
|
[tool.basedpyright]
|
|
|
|
pythonPlatform = "All"
|
2024-04-25 17:46:34 +00:00
|
|
|
pythonVersion = "3.11"
|
Move to a much stricter pyright configuration
This moves us from using the "standard" type-checking mode (which has a
lot of the diagnostic rules disabled, which meant we were almost in a
whitelist-based system, where most diagnostic rules were disabled unless
explicitly enabled) to "all" (where all diagnotic rules are enabled,
except for those explicitly disabled, moving us to a blacklist-based
system).
The current configuration here is very strict and might not fit all
code-bases, but it will work very well for new projects, as this
strictness, while slightly annoying sometimes, forces a lot better and
more correct typing to the previous set of rules.
This template still leaves the rules for reporting unknown types
disabled, as these are incredibly strict and while they can definitely
be beneficial, for most people it's too big of an annoyance for what
it's worth.
2024-07-13 11:01:45 +00:00
|
|
|
typeCheckingMode = "all"
|
|
|
|
|
|
|
|
# Diagnostic behavior settings
|
|
|
|
strictListInference = false
|
|
|
|
strictDictionaryInference = false
|
|
|
|
strictSetInference = false
|
|
|
|
analyzeUnannotatedFunctions = true
|
|
|
|
strictParameterNoneValue = true
|
|
|
|
enableTypeIgnoreComments = true
|
|
|
|
deprecateTypingAliases = true
|
|
|
|
enableExperimentalFeatures = false
|
|
|
|
disableBytesTypePromotions = true
|
|
|
|
|
|
|
|
# Diagnostic rules
|
|
|
|
reportAny = false
|
|
|
|
reportImplicitStringConcatenation = false
|
|
|
|
reportUnreachable = "information"
|
|
|
|
reportMissingTypeStubs = "information"
|
|
|
|
reportUninitializedInstanceVariable = false # until https://github.com/DetachHead/basedpyright/issues/491
|
|
|
|
reportMissingParameterType = false # ruff's flake8-annotations (ANN) already covers this + gives us more control
|
|
|
|
|
|
|
|
# Unknown type reporting rules (too strict for most code-bases)
|
|
|
|
reportUnknownArgumentType = false
|
|
|
|
reportUnknownVariableType = false
|
|
|
|
reportUnknownMemberType = false
|
|
|
|
reportUnknownParameterType = false
|
|
|
|
reportUnknownLambdaType = false
|
2024-06-30 20:35:14 +00:00
|
|
|
|
|
|
|
[tool.pytest.ini_options]
|
|
|
|
minversion = "6.0"
|
|
|
|
asyncio_mode = "auto"
|
|
|
|
testpaths = ["tests"]
|
|
|
|
addopts = "--strict-markers --cov --no-cov-on-fail"
|
|
|
|
|
|
|
|
[tool.coverage.report]
|
|
|
|
precision = 2
|
|
|
|
fail_under = 20
|
|
|
|
show_missing = true
|
|
|
|
skip_covered = false
|
|
|
|
skip_empty = false
|
|
|
|
sort = "cover"
|
|
|
|
exclude_lines = [
|
|
|
|
"\\#\\s*pragma: no cover",
|
|
|
|
"^\\s*if (typing\\.)?TYPE_CHECKING:",
|
|
|
|
"^\\s*@(abc\\.)?abstractmethod",
|
|
|
|
"^\\s*@(typing\\.)?overload",
|
|
|
|
"^\\s*def __repr__\\(",
|
|
|
|
"^\\s*class .*\\bProtocol\\):",
|
|
|
|
"^\\s*raise NotImplementedError",
|
|
|
|
"^\\s*return NotImplemented",
|
|
|
|
"^\\s*\\.\\.\\.",
|
|
|
|
]
|
|
|
|
|
|
|
|
[tool.coverage.run]
|
|
|
|
relative_files = true
|
|
|
|
parallel = true
|
|
|
|
branch = true
|
|
|
|
timid = false
|
|
|
|
source = ["src"]
|
2024-06-30 20:42:27 +00:00
|
|
|
|
|
|
|
[tool.poe.tasks.precommit]
|
|
|
|
cmd = "pre-commit install"
|
|
|
|
help = "install pre-commit hooks"
|
|
|
|
|
|
|
|
[tool.poe.tasks.lint]
|
|
|
|
cmd = "pre-commit run --all-files"
|
|
|
|
help = "Run all project linters (via pre-commit)"
|
|
|
|
|
|
|
|
[tool.poe.tasks.ruff]
|
|
|
|
cmd = "ruff check --fix ."
|
|
|
|
help = "Run ruff linter, with automatic issue fixing"
|
|
|
|
|
|
|
|
[tool.poe.tasks.ruff-format]
|
|
|
|
cmd = "ruff format ."
|
|
|
|
help = "Run ruff formatter"
|
|
|
|
|
|
|
|
[tool.poe.tasks.test]
|
|
|
|
cmd = "pytest -v --failed-first"
|
|
|
|
help = "Run pytest tests"
|
|
|
|
|
2024-07-10 15:30:22 +00:00
|
|
|
[tool.poe.tasks.pyright]
|
2024-07-13 10:59:17 +00:00
|
|
|
cmd = "basedpyright --warnings ."
|
2024-07-10 15:30:22 +00:00
|
|
|
help = "Run BasedPyright type-checker"
|
|
|
|
|
2024-06-30 20:42:27 +00:00
|
|
|
[tool.poe.tasks.retest]
|
|
|
|
cmd = "pytest -v --last-failed"
|
|
|
|
help = "Run previously failed tests using pytest"
|
|
|
|
|
|
|
|
[tool.poe.tasks.test-nocov]
|
|
|
|
cmd = "pytest -v --no-cov --failed-first"
|
|
|
|
help = "Run pytest tests without coverage"
|
|
|
|
|
|
|
|
[tool.poe.tasks.retest-nocov]
|
|
|
|
cmd = "pytest -v --no-cov --last-failed"
|
|
|
|
help = "Run previously failed tests using pytest without coverage"
|