diff --git a/.flake8 b/.flake8 deleted file mode 100644 index c0b7bdb8..00000000 --- a/.flake8 +++ /dev/null @@ -1,29 +0,0 @@ -[flake8] -filename = - ./scripts/*.py, - ./src/*.py, - ./tests/*.py -per-file-ignores = - scripts/*: D - tests/*: D - -# Google docstring convention + D204 & D401 -docstring-convention = all -ignore = - D100 - D104 - D203 - D213 - D215 - D406 - D407 - D408 - D409 - D413 - U101 - -max_line_length = 150 -unused-arguments-ignore-overload-functions = True -unused-arguments-ignore-stub-functions = True -pytest-fixture-no-parentheses = True -pytest-mark-no-parentheses = True diff --git a/.gitignore b/.gitignore index e05d411c..a89c2ed0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ __pycache__ .mypy_cache .pytest_cache +.ruff_cache .venv .direnv diff --git a/Makefile b/Makefile index 31d6dab8..a21ef25b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ .PHONY: clean install-dev build publish twine-check lint unit-tests integration-tests type-check check-code format check-version-availability check-changelog-entry build-api-reference +DIRS_WITH_CODE = src tests scripts + # This is default for local testing, but GitHub workflows override it to a higher value in CI INTEGRATION_TESTS_CONCURRENCY = 1 @@ -21,7 +23,7 @@ twine-check: python -m twine check dist/* lint: - python3 -m flake8 + python3 -m ruff check $(DIRS_WITH_CODE) unit-tests: python3 -m pytest -n auto -ra tests/unit @@ -30,13 +32,13 @@ integration-tests: python3 -m pytest -n $(INTEGRATION_TESTS_CONCURRENCY) -ra tests/integration type-check: - python3 -m mypy + python3 -m mypy $(DIRS_WITH_CODE) check-code: lint type-check unit-tests format: - python3 -m isort src tests - python3 -m autopep8 --in-place --recursive src tests + python3 -m isort $(DIRS_WITH_CODE) + python3 -m ruff format $(DIRS_WITH_CODE) check-version-availability: python3 scripts/check_version_availability.py diff --git a/pyproject.toml b/pyproject.toml index 304e2304..5a7bd7de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,10 +3,8 @@ name = "apify" version = "1.2.1" description = "Apify SDK for Python" readme = "README.md" -license = {text = "Apache Software License"} -authors = [ - {name = "Apify Technologies s.r.o.", email = "support@apify.com"}, -] +license = { text = "Apache Software License" } +authors = [{ name = "Apify Technologies s.r.o.", email = "support@apify.com" }] keywords = ["apify", "sdk", "actor", "scraping", "automation"] classifiers = [ @@ -40,25 +38,10 @@ dependencies = [ [project.optional-dependencies] dev = [ - "autopep8 ~= 2.0.4", "build ~= 1.0.3", "filelock ~= 3.12.4", - "flake8 ~= 6.1.0", - "flake8-bugbear ~= 23.9.16", - "flake8-commas ~= 2.1.0; python_version < '3.12'", - "flake8-comprehensions ~= 3.14.0", - "flake8-datetimez ~= 20.10.0", - "flake8-docstrings ~= 1.7.0", - "flake8-encodings ~= 0.5.0", - "flake8-isort ~= 6.1.0", - "flake8-noqa ~= 1.3.1; python_version < '3.12'", - "flake8-pytest-style ~= 1.7.2", - "flake8-quotes ~= 3.3.2; python_version < '3.12'", - "flake8-simplify ~= 0.21.0", - "flake8-unused-arguments ~= 0.0.13", "isort ~= 5.12.0", - "mypy ~= 1.5.1", - "pep8-naming ~= 0.13.3", + "mypy ~= 1.7.0", "pre-commit ~= 3.4.0", "pydoc-markdown ~= 4.8.2", "pytest ~= 7.4.2", @@ -67,6 +50,7 @@ dev = [ "pytest-timeout ~= 2.2.0", "pytest-xdist ~= 3.3.1", "respx ~= 0.20.1", + "ruff ~= 0.1.5", "twine ~= 4.0.2", "types-aiofiles ~= 23.2.0.0", "types-colorama ~= 0.4.15.11", @@ -91,3 +75,41 @@ include = ["apify*"] [tool.setuptools.package-data] apify = ["py.typed"] + +[tool.ruff] +line-length = 150 +select = ["ALL"] +ignore = [ + "BLE001", # Do not catch blind exception + "COM812", # This rule may cause conflicts when used with the formatter + "D100", # Missing docstring in public module + "D104", # Missing docstring in public package + "EM", # flake8-errmsg + "ISC001", # This rule may cause conflicts when used with the formatter + "FIX", # flake8-fixme + "PGH003", # Use specific rule codes when ignoring type issues + "PLR0913", # Too many arguments in function definition + "PTH123", # `open()` should be replaced by `Path.open()` + "S102", # Use of `exec` detected + "S105", # Possible hardcoded password assigned to + "TRY003", # Avoid specifying long messages outside the exception class +] + +[tool.ruff.format] +quote-style = "single" +indent-style = "space" + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401"] +"**/{scripts}/*" = ["D", "INP"] +"**/{tests}/*" = ["D", "INP", "S101"] + +[tool.ruff.lint.flake8-quotes] +docstring-quotes = "double" +inline-quotes = "single" + +[tool.ruff.lint.isort] +known-first-party = ["apify", "apify_client", "apify_shared"] + +[tool.ruff.lint.pydocstyle] +convention = "google"