Skip to content

Commit

Permalink
Add configs
Browse files Browse the repository at this point in the history
  • Loading branch information
vdusek committed Nov 16, 2023
1 parent 426f5a7 commit 0a4a356
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 70 deletions.
30 changes: 0 additions & 30 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
7 changes: 0 additions & 7 deletions .isort.cfg

This file was deleted.

6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Changelog
=========

[1.3.1](../../releases/tag/v1.3.1) - Unreleased
[1.4.0](../../releases/tag/v1.4.0) - Unreleased
-----------------------------------------------

...
### Internal changes

- Migrate from Autopep8 and Flake8 to Ruff

[1.3.0](../../releases/tag/v1.3.0) - 2023-11-15
-----------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ To install this package and its development dependencies, run `make install-dev`

## Formatting

We use `autopep8` and `isort` to automatically format the code to a common format. To run the formatting, just run `make format`.
We use `ruff` to automatically format the code to a common format. To run the formatting, just run `make format`.

## Linting, type-checking and unit testing

We use `flake8` for linting, `mypy` for type checking and `pytest` for unit testing. To run these tools, just run `make check-code`.
We use `ruff` for linting, `mypy` for type checking and `pytest` for unit testing. To run these tools, just run `make check-code`.

## Integration tests

Expand Down
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
.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

clean:
rm -rf build dist .mypy_cache .pytest_cache src/*.egg-info __pycache__

install-dev:
python -m pip install --upgrade pip
python3 -m pip install --upgrade pip
pip install --no-cache-dir -e ".[dev,scrapy]"
pre-commit install

build:
python -m build
python3 -m build

publish:
python -m twine upload dist/*
python3 -m twine upload dist/*

twine-check:
python -m twine check dist/*
python3 -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 ruff check --fix $(DIRS_WITH_CODE)
python3 -m ruff format $(DIRS_WITH_CODE)

check-version-availability:
python3 scripts/check_version_availability.py
Expand Down
78 changes: 57 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ name = "apify"
version = "1.3.1"
description = "Apify SDK for Python"
readme = "README.md"
license = {text = "Apache Software License"}
authors = [
{name = "Apify Technologies s.r.o.", email = "[email protected]"},
]
license = { text = "Apache Software License" }
authors = [{ name = "Apify Technologies s.r.o.", email = "[email protected]" }]
keywords = ["apify", "sdk", "actor", "scraping", "automation"]

classifiers = [
Expand Down Expand Up @@ -40,25 +38,9 @@ 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 +49,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 Down Expand Up @@ -94,3 +77,56 @@ include = ["apify*"]

[tool.setuptools.package-data]
apify = ["py.typed"]

[tool.ruff]
line-length = 150
select = ["ALL"]
ignore = [
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {filename}
"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
"TID252", # Relative imports from parent modules are bannedRuff
"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", # Unused imports
]
"**/{scripts}/*" = [
"D", # Everything from the pydocstyle
"INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
"T20", # flake8-print
]
"**/{tests}/*" = [
"D", # Everything from the pydocstyle
"INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
"T20", # flake8-print
"S101", # Use of assert detected
]

[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 0a4a356

Please sign in to comment.