Skip to content

Commit

Permalink
Move configurations to pyproject.toml, use ruff (#754)
Browse files Browse the repository at this point in the history
* Move configurations to pyproject.toml, use ruff instead of flake8, autoflake and isort

* Add --fix for ruff

* Add ruff to requirements

* Add black

* Fix omit and include

* Add isort

* Add show-source option to ruff check

* Drop isort configs

Co-authored-by: Zanie <contact@zanie.dev>

* Remove autoflake from scripts/lint

---------

Co-authored-by: Zanie <contact@zanie.dev>
  • Loading branch information
karpetrosyan and zanieb committed Jul 13, 2023
1 parent e32b2ad commit 0211d10
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 45 deletions.
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,48 @@ path = "README.md"

[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
path = "CHANGELOG.md"

[tool.mypy]
strict = true
show_error_codes = true

[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false
check_untyped_defs = true

[[tool.mypy.overrides]]
module = "h2.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "hpack.*"
ignore_missing_imports = true

[tool.pytest.ini_options]
addopts = ["-rxXs", "--strict-config", "--strict-markers"]
markers = ["copied_from(source, changes=None): mark test as copied from somewhere else, along with a description of changes made to accodomate e.g. our test setup"]
filterwarnings = ["error"]

[tool.coverage.run]
omit = [
"venv/*",
"httpcore/_sync/*"
]
include = ["httpcore/*", "tests/*"]

[tool.ruff]
exclude = [
"httpcore/_sync",
"tests/_sync",
]
line-length = 120
select = [
"E",
"F",
"W",
"I"
]

[tool.ruff.isort]
combine-as-imports = true
7 changes: 2 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ twine

# Tests & Linting
anyio==3.6.2
autoflake==1.7.7
black==23.3.0
coverage==7.2.7
flake8==3.9.2 # See: https://github.com/PyCQA/flake8/pull/1438
isort==5.11.4
importlib-metadata==4.13.0
coverage[toml]==7.2.7
ruff==0.0.277
mypy==1.2.0
trio-typing==0.8.0
types-certifi==2021.10.8.3
Expand Down
3 changes: 1 addition & 2 deletions scripts/check
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export SOURCE_FILES="httpcore tests"

set -x

${PREFIX}isort --check --diff --project=httpcore $SOURCE_FILES
${PREFIX}ruff check --show-source $SOURCE_FILES
${PREFIX}black --exclude '/(_sync|sync_tests)/' --check --diff --target-version=py37 $SOURCE_FILES
${PREFIX}flake8 $SOURCE_FILES
${PREFIX}mypy $SOURCE_FILES
scripts/unasync --check
3 changes: 1 addition & 2 deletions scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export SOURCE_FILES="httpcore tests"

set -x

${PREFIX}autoflake --in-place --recursive --remove-all-unused-imports $SOURCE_FILES
${PREFIX}isort --project=httpcore $SOURCE_FILES
${PREFIX}ruff --fix $SOURCE_FILES
${PREFIX}black --target-version=py37 --exclude '/(_sync|sync_tests)/' $SOURCE_FILES

# Run unasync last because its `--check` mode is not aware of code formatters.
Expand Down
36 changes: 0 additions & 36 deletions setup.cfg

This file was deleted.

0 comments on commit 0211d10

Please sign in to comment.