Add isort and ruff as dev dependencies;

 remove `flake8` dependency (replaced by `ruff`);
change `lint.sh` script to use `isort`, `ruff`, and `black`
This commit is contained in:
Daniil Fajnberg 2023-03-10 16:57:26 +01:00
parent f3087bfe66
commit 692e5ef4c4
Signed by: daniil-berg
GPG Key ID: BE187C50903BEE97
7 changed files with 47 additions and 13 deletions

View File

@ -44,10 +44,11 @@ dev = [
"black", "black",
"build", "build",
"coverage[toml]", "coverage[toml]",
"flake8", "isort",
"mkdocs-material", "mkdocs-material",
"mkdocstrings[python]", "mkdocstrings[python]",
"mypy", "mypy",
"ruff",
] ]
[project.urls] [project.urls]
@ -60,8 +61,8 @@ dependencies = { file = "requirements/common.txt" }
readme = { file = ["README.md"] } readme = { file = ["README.md"] }
version = {attr = "marshmallow_generic.__version__"} version = {attr = "marshmallow_generic.__version__"}
######### #########################
# Mypy: # # Static type checking: #
[tool.mypy] [tool.mypy]
files = [ files = [
@ -75,8 +76,8 @@ plugins = [
] ]
############# #######################
# Coverage: # # Unit test coverage: #
[tool.coverage.run] [tool.coverage.run]
source = [ source = [
@ -99,3 +100,38 @@ exclude_lines = [
omit = [ omit = [
"tests/*", "tests/*",
] ]
###############################
# Linting and style checking: #
[tool.ruff]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"D", # pydocstyle
"C", # flake8-comprehensions
"B", # flake8-bugbear
"PL", # pylint
"RUF", # ruff-specific
]
ignore = [
"E501", # Line too long -> handled by black
"D203", # 1 blank line required before class docstring -> D211 is better
"D212", # Multi-line docstring summary should start at the first line -> ugly, D212 is better
]
[tool.ruff.per-file-ignores]
"tests/*.py" = [
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D104", # Missing docstring in public package
]
###################
# Import sorting: #
[tool.isort]
profile = "black"
extra_standard_library = ["typing_extensions"]

View File

@ -2,7 +2,8 @@
black black
build build
coverage[toml] coverage[toml]
flake8 isort
mkdocs-material mkdocs-material
mkdocstrings[python] mkdocstrings[python]
mypy mypy
ruff

View File

@ -12,5 +12,7 @@ mypy
echo echo
echo 'Linting source and test files...' echo 'Linting source and test files...'
flake8 src/ tests/ isort src/ tests/ --check-only
ruff src/ tests/
black src/ tests/ --check
echo -e 'No issues found.' echo -e 'No issues found.'

View File

@ -1,6 +1,5 @@
from typing import Any, Generic, Optional, TypeVar, get_args, get_origin from typing import Any, Generic, Optional, TypeVar, get_args, get_origin
_T = TypeVar("_T") _T = TypeVar("_T")

View File

@ -4,7 +4,6 @@ from typing_extensions import ParamSpec
from marshmallow.decorators import post_load as _post_load from marshmallow.decorators import post_load as _post_load
_R = TypeVar("_R") _R = TypeVar("_R")
_P = ParamSpec("_P") _P = ParamSpec("_P")

View File

@ -1,7 +1,6 @@
import sys import sys
import unittest import unittest
if __name__ == "__main__": if __name__ == "__main__":
try: try:
pattern = sys.argv[1] pattern = sys.argv[1]

View File

@ -12,9 +12,7 @@ class GenericInsightMixinTestCase(TestCase):
mock_super.return_value = MagicMock(__init_subclass__=mock_super_meth) mock_super.return_value = MagicMock(__init_subclass__=mock_super_meth)
# Should be `None` by default: # Should be `None` by default:
self.assertIsNone( self.assertIsNone(_util.GenericInsightMixin._type_arg) # type: ignore[misc]
_util.GenericInsightMixin._type_arg # type: ignore[misc]
)
# If the mixin type argument was not specified (still generic), # If the mixin type argument was not specified (still generic),
# ensure that the attribute remains `None` on the subclass: # ensure that the attribute remains `None` on the subclass: