Skip to content

Commit f56d393

Browse files
authored
Add ruff (#35)
1 parent acaf1dd commit f56d393

File tree

9 files changed

+63
-65
lines changed

9 files changed

+63
-65
lines changed

.github/workflows/check.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
py:
21-
- "3.12.0-beta.1"
21+
- "3.12.0-beta.2"
2222
- "3.11"
2323
- "3.10"
2424
- "3.9"
2525
- "3.8"
2626
- "3.7"
2727
os:
28-
- ubuntu-22.04
28+
- ubuntu-latest
2929

3030
steps:
3131
- name: Setup python for tox
@@ -63,7 +63,7 @@ jobs:
6363
fail-fast: false
6464
matrix:
6565
os:
66-
- ubuntu-22.04
66+
- ubuntu-latest
6767
tox_env:
6868
- dev
6969
- type

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
release:
8-
runs-on: ubuntu-22.04
8+
runs-on: ubuntu-latest
99
environment:
1010
name: release
1111
url: https://pypi.org/p/pytest-env

.pre-commit-config.yaml

+17-40
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,33 @@ repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v4.4.0
44
hooks:
5-
- id: check-ast
6-
- id: check-builtin-literals
7-
- id: check-docstring-first
8-
- id: check-merge-conflict
9-
- id: check-yaml
10-
- id: check-toml
11-
- id: debug-statements
125
- id: end-of-file-fixer
136
- id: trailing-whitespace
14-
- repo: https://github.com/asottile/pyupgrade
15-
rev: v3.3.1
7+
- repo: https://github.com/astral-sh/ruff-pre-commit
8+
rev: "v0.0.272"
169
hooks:
17-
- id: pyupgrade
18-
args: [ "--py37-plus" ]
19-
- repo: https://github.com/PyCQA/isort
20-
rev: 5.12.0
21-
hooks:
22-
- id: isort
10+
- id: ruff
11+
args: [--fix, --exit-non-zero-on-fix]
2312
- repo: https://github.com/psf/black
2413
rev: 23.3.0
2514
hooks:
2615
- id: black
27-
args: [ --safe ]
28-
- repo: https://github.com/asottile/blacken-docs
29-
rev: 1.13.0
30-
hooks:
31-
- id: blacken-docs
32-
additional_dependencies: [ black==23.3 ]
33-
- repo: https://github.com/pre-commit/pygrep-hooks
34-
rev: v1.10.0
35-
hooks:
36-
- id: rst-backticks
3716
- repo: https://github.com/tox-dev/tox-ini-fmt
3817
rev: "1.3.0"
3918
hooks:
4019
- id: tox-ini-fmt
41-
args: [ "-p", "fix" ]
42-
- repo: https://github.com/PyCQA/flake8
43-
rev: 6.0.0
44-
hooks:
45-
- id: flake8
46-
additional_dependencies:
47-
- flake8-bugbear==23.3.23
48-
- flake8-comprehensions==3.12
49-
- flake8-pytest-style==1.7.2
50-
- flake8-spellcheck==0.28
51-
- flake8-unused-arguments==0.0.13
52-
- flake8-noqa==1.3.1
53-
- pep8-naming==0.13.3
20+
args: ["-p", "fix"]
5421
- repo: https://github.com/tox-dev/pyproject-fmt
55-
rev: "0.9.2"
22+
rev: "0.11.2"
23+
hooks:
24+
- id: pyproject-fmt
25+
additional_dependencies: ["tox>=4.6"]
26+
- repo: https://github.com/pre-commit/mirrors-prettier
27+
rev: "v3.0.0-alpha.9-for-vscode"
28+
hooks:
29+
- id: prettier
30+
args: ["--print-width=120", "--prose-wrap=always"]
31+
- repo: meta
5632
hooks:
57-
- id: pyproject-fmt
33+
- id: check-hooks-apply
34+
- id: check-useless-excludes

pyproject.toml

+30-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
build-backend = "hatchling.build"
33
requires = [
44
"hatch-vcs>=0.3",
5-
"hatchling>=1.14",
5+
"hatchling>=1.17.1",
66
]
77

88
[project]
@@ -22,8 +22,13 @@ classifiers = [
2222
"License :: OSI Approved :: MIT License",
2323
"Operating System :: OS Independent",
2424
"Programming Language :: Python",
25-
"Programming Language :: Python :: 3",
2625
"Programming Language :: Python :: 3 :: Only",
26+
"Programming Language :: Python :: 3.7",
27+
"Programming Language :: Python :: 3.8",
28+
"Programming Language :: Python :: 3.9",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
2732
"Programming Language :: Python :: Implementation :: CPython",
2833
"Topic :: Software Development :: Libraries :: Python Modules",
2934
]
@@ -34,7 +39,7 @@ dependencies = [
3439
"pytest>=7.3.1",
3540
]
3641
optional-dependencies.test = [
37-
"coverage>=7.2.3",
42+
"coverage>=7.2.7",
3843
"pytest-mock>=3.10",
3944
]
4045
urls.Homepage = "https://github.com/pytest-dev/pytest-env"
@@ -76,3 +81,25 @@ paths.source = [
7681
python_version = "3.10"
7782
show_error_codes = true
7883
strict = true
84+
85+
[tool.ruff]
86+
select = ["ALL"]
87+
line-length = 120
88+
target-version = "py37"
89+
isort = {known-first-party = ["pytest_env"], required-imports = ["from __future__ import annotations"]}
90+
ignore = [
91+
"ANN101", # no typoe annotation for self
92+
"ANN401", # allow Any as type annotation
93+
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
94+
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
95+
"S104", # Possible binding to all interface
96+
]
97+
[tool.ruff.per-file-ignores]
98+
"tests/**/*.py" = [
99+
"S101", # asserts allowed in tests...
100+
"FBT", # don"t care about booleans as positional arguments in tests
101+
"INP001", # no implicit namespace
102+
"D", # don"t care about documentation in tests
103+
"S603", # `subprocess` call: check for execution of untrusted input
104+
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
105+
]

src/pytest_env/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Pytest set environments."""
12
from __future__ import annotations
23

34
from .version import __version__

src/pytest_env/plugin.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ def pytest_addoption(parser: pytest.Parser) -> None:
1212
parser.addini("env", type="linelist", help=help_msg, default=[])
1313

1414

15-
@pytest.hookimpl(tryfirst=True) # type: ignore # untyped decorator
15+
@pytest.hookimpl(tryfirst=True) # type: ignore[misc]
1616
def pytest_load_initial_conftests(
17-
args: list[str], early_config: pytest.Config, parser: pytest.Parser # noqa: U100
17+
args: list[str], # noqa: ARG001
18+
early_config: pytest.Config,
19+
parser: pytest.Parser, # noqa: ARG001
1820
) -> None:
1921
"""Load environment variables from configuration files."""
2022
for line in early_config.getini("env"):

tests/test_env.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@
9393
],
9494
)
9595
def test_env(
96-
testdir: pytest.Testdir, env: dict[str, str], ini: str, expected_env: dict[str, str], request: pytest.FixtureRequest
96+
testdir: pytest.Testdir,
97+
env: dict[str, str],
98+
ini: str,
99+
expected_env: dict[str, str],
100+
request: pytest.FixtureRequest,
97101
) -> None:
98102
tmp_dir = Path(str(testdir.tmpdir))
99103
test_name = re.sub(r"\W|^(?=\d)", "_", request.node.callspec.id).lower()

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ commands =
3434
description = run static analysis and style check using flake8
3535
skip_install = true
3636
deps =
37-
pre-commit>=3.2.2
37+
pre-commit>=3.2.
3838
pass_env =
3939
HOMEPATH
4040
PROGRAMDATA
@@ -44,7 +44,7 @@ commands =
4444
[testenv:type]
4545
description = run type check on code base
4646
deps =
47-
mypy==1.2
47+
mypy==1.3
4848
set_env =
4949
{tty:MYPY_FORCE_COLOR = 1}
5050
commands =

whitelist.txt

-13
This file was deleted.

0 commit comments

Comments
 (0)