Skip to content

Commit

Permalink
Migrate from Flake8 & Autopep8 to Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
vdusek committed Nov 13, 2023
1 parent e238be4 commit 380510e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 53 deletions.
29 changes: 0 additions & 29 deletions .flake8

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__pycache__
.mypy_cache
.pytest_cache
.ruff_cache

.venv
.direnv
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
62 changes: 42 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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"

0 comments on commit 380510e

Please sign in to comment.