Skip to content

Commit

Permalink
replaced isort and black by ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
TeKrop committed Oct 27, 2023
1 parent c4b8908 commit 6dbbd16
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 34 deletions.
21 changes: 6 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
default_language_version:
python: python3.11
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: (isort) Sorting python imports
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
name: (black) Formatting code
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.284
rev: v0.1.3
hooks:
- id: ruff
name: (ruff) Checking code quality
args: [ --fix, --exit-non-zero-on-fix ]
name: (ruff) Linting and fixing code
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
name: (ruff) Formatting code
- repo: https://github.com/sourcery-ai/sourcery
rev: v1.7.0
rev: v1.11.0
hooks:
- id: sourcery
name: (sourcery) Checking code quality
Expand Down
2 changes: 1 addition & 1 deletion app/commands/update_test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def main():
response.status_code,
response.elapsed.total_seconds(),
)
if response.status_code in (status.HTTP_200_OK, status.HTTP_404_NOT_FOUND):
if response.status_code in {status.HTTP_200_OK, status.HTTP_404_NOT_FOUND}:
save_fixture_file(f"{test_data_path}{filepath}", response.text)
else:
logger.error("Error while getting the page : {}", response.text)
Expand Down
42 changes: 25 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ documentation = "https://overfast-api.tekrop.fr/"
[tool.poetry.dependencies]
python = "^3.11"
beautifulsoup4 = "^4.12.2"
fastapi = "^0.103.2"
fastapi = "^0.104.0"
httpx = {extras = ["http2"], version = "^0.25.0"}
loguru = "^0.7.2"
lxml = "^4.9.3"
Expand All @@ -22,45 +22,37 @@ pydantic = "^2.4.2"
pydantic-settings = "^2.0.3"

[tool.poetry.group.dev.dependencies]
black = "^23.9.1"
fakeredis = "^2.19.0"
fakeredis = "^2.20.0"
ipdb = "^0.13.13"
isort = "^5.12.0"
pytest = "^7.4.2"
pytest = "^7.4.3"
pytest-asyncio = "^0.21.1"
pytest-clarity = "^1.0.1"
pytest-cov = "^4.1.0"
pytest-randomly = "^3.15.0"
pytest-xdist = "^3.3.1"
refurb = "^1.21.0"
ruff = "^0.0.292"
pre-commit = "^3.4.0"
sourcery = "^1.10.1"
refurb = "^1.22.1"
ruff = "^0.1.3"
pre-commit = "^3.5.0"
sourcery = "^1.11.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
profile = "black"

[tool.ruff]
# Same configuration as black default
line-length = 88

select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"C90", # mccabe complexity checker
"I001", # isort
"N", # pep8-naming
"UP", # pyupgrade
"ASYNC", # flake8-async
"S", # flake8-bandit
"BLE", # flake8-blind-except
"B", # flake8-bugbear
"COM", # flake8-commas
"CPY", # flake8-copyright
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
Expand All @@ -75,6 +67,7 @@ select = [
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"T20", # flake8-print
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RSE", # flake8-raise
Expand All @@ -96,17 +89,32 @@ select = [
"RUF", # ruff-specific rules
]
ignore = [
"E501", # line too long, handled by black
# General rules to ignore
"B008", # do not perform function calls in argument defaults
"S101", # using "assert" is not a security issue
"S311", # there is no cryptographic usage of random here
"RET505", # allow using else after return statement
"PLE1205", # error checking doesn't support {} format
"PLR0913", # allow 6/7 arguments for some functions

# Rules already handled by ruff formatter
"E501", # line too long
"COM812", # missing trailing comma
"COM819", # prohibited trailing comma
"ISC001", # single line implicit string concatenation
"Q000", # bad quotes in inline string
"Q001", # bad quotes in multiline string
"Q002", # bad quotes in docstring
"Q003", # avoidable escape quote
"W191" # tab indentation detected instead of spaces
]

# Check app code and tests
src = ["app", "tests"]

# Assume Python 3.11
target-version = "py311"

[tool.ruff.isort]
# Consider app as first-party for imports in tests
known-first-party = ["app"]
2 changes: 1 addition & 1 deletion tests/parsers/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
("string", "string"),
],
)
def test_get_computed_stat_value(input_str: str, result: int | float | str):
def test_get_computed_stat_value(input_str: str, result: float | str):
assert helpers.get_computed_stat_value(input_str) == result


Expand Down

0 comments on commit 6dbbd16

Please sign in to comment.