Skip to content

Commit

Permalink
Use ruff (#359)
Browse files Browse the repository at this point in the history
* Add config

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>

* Add config

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>

* Run formatter

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>

* Fix type annotations

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>

* Finalize fixes

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>

---------

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat authored Jun 15, 2023
1 parent d7613ad commit a021cc8
Show file tree
Hide file tree
Showing 22 changed files with 529 additions and 460 deletions.
61 changes: 9 additions & 52 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,33 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: check-merge-conflict
- id: check-yaml
- id: check-toml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.272"
hooks:
- id: pyupgrade
args: ["--py38-plus"]
exclude: "^(tests/roots/test-dummy/dummy_module.py)$"
- id: pyupgrade
files: "^(tests/roots/test-dummy/dummy_module.py)$"
args: ["--py36-plus"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [--safe]
- repo: https://github.com/asottile/blacken-docs
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.3]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.3.0"
hooks:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.11.2"
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.3.23
- flake8-comprehensions==3.12
- flake8-pytest-style==1.7.2
- flake8-spellcheck==0.28
- flake8-unused-arguments==0.0.13
- flake8-noqa==1.3.1
- pep8-naming==0.13.3
- id: pyproject-fmt
additional_dependencies: ["tox>=4.6"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
rev: "v3.0.0-alpha.9-for-vscode"
hooks:
- id: prettier
additional_dependencies:
- prettier@2.7.1
- "@prettier/plugin-xml@2.2"
args: ["--print-width=120", "--prose-wrap=always"]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
hooks:
- id: markdownlint
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.9.2"
hooks:
- id: pyproject-fmt
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@

## 1.2.1

- Fixed `` ValueError` when ``getargspec()\`\` encounters a built-in function
- Fixed ``ValueError` when``getargspec()\`\` encounters a built-in function
- Fixed `AttributeError` when `Any` is combined with another type in a `Union` (thanks Davis Kirkendall)

## 1.2.0
Expand Down
51 changes: 34 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-backend = "hatchling.build"
requires = [
"hatch-vcs>=0.3",
"hatchling>=1.14",
"hatchling>=1.17.1",
]

[project]
Expand All @@ -26,30 +26,34 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Documentation :: Sphinx",
]
dynamic = [
"version",
]
dependencies = [
"Sphinx>=6.1.3",
"Sphinx>=7.0.1",
]
optional-dependencies.docs = [
"furo>=2023.3.27",
"sphinx>=6.1.3",
"furo>=2023.5.20",
"sphinx>=7.0.1",
"sphinx-autodoc-typehints>=1.23.4",
]
optional-dependencies.testing = [
"covdefaults>=2.3",
"coverage>=7.2.3",
"coverage>=7.2.7",
"diff-cover>=7.5",
"nptyping>=2.5",
"pytest>=7.3.1",
"pytest-cov>=4",
"pytest-cov>=4.1",
"sphobjinv>=2.3.1",
"typing-extensions>=4.5",
"typing-extensions>=4.6.3",
]
optional-dependencies.type-comment = [
'typed-ast>=1.5.4; python_version < "3.8"',
Expand All @@ -66,11 +70,6 @@ version.source = "vcs"
[tool.black]
line-length = 120

[tool.isort]
line_length = 120
profile = "black"
known_first_party = ["sphinx_autodoc_typehints", "tests"]

[tool.pytest.ini_options]
testpaths = ["tests"]

Expand All @@ -94,8 +93,26 @@ run.plugins = ["covdefaults"]
python_version = "3.10"
strict = true
exclude = "^(.*/roots/.*)|(tests/test_integration.py)$"
overrides = [{ module = ["sphobjinv.*"], ignore_missing_imports = true }]


[[tool.mypy.overrides]]
module = ["sphobjinv"]
ignore_missing_imports = true
[tool.ruff]
select = ["ALL"]
line-length = 120
target-version = "py37"
isort = {known-first-party = ["tox", "tests"], required-imports = ["from __future__ import annotations"]}
ignore = [
"ANN101", # no typoe annotation for self
"ANN401", # allow Any as type annotation
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
"S104", # Possible binding to all interface
]
[tool.ruff.per-file-ignores]
"tests/**/*.py" = [
"S101", # asserts allowed in tests...
"FBT", # don"t care about booleans as positional arguments in tests
"INP001", # no implicit namespace
"D", # don"t care about documentation in tests
"S603", # `subprocess` call: check for execution of untrusted input
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
]
Loading

0 comments on commit a021cc8

Please sign in to comment.