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 601fee0bfc
commit 25cbe8de4b
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",
"build",
"coverage[toml]",
"flake8",
"isort",
"mkdocs-material",
"mkdocstrings[python]",
"mypy",
"ruff",
]
[project.urls]
@ -60,8 +61,8 @@ dependencies = { file = "requirements/common.txt" }
readme = { file = ["README.md"] }
version = {attr = "marshmallow_generic.__version__"}
#########
# Mypy: #
#########################
# Static type checking: #
[tool.mypy]
files = [
@ -75,8 +76,8 @@ plugins = [
]
#############
# Coverage: #
#######################
# Unit test coverage: #
[tool.coverage.run]
source = [
@ -99,3 +100,38 @@ exclude_lines = [
omit = [
"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
build
coverage[toml]
flake8
isort
mkdocs-material
mkdocstrings[python]
mypy
ruff

View File

@ -12,5 +12,7 @@ mypy
echo
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.'

View File

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

View File

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

View File

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

View File

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