Skip to content

Commit 6ffc213

Browse files
committed
Use ruff
1 parent 3d594e4 commit 6ffc213

File tree

5 files changed

+35
-40
lines changed

5 files changed

+35
-40
lines changed

.flake8

Lines changed: 0 additions & 16 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.4.0
6+
rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 # v4.4.0
77
hooks:
88
- id: trailing-whitespace
99
- id: end-of-file-fixer
@@ -15,27 +15,21 @@ repos:
1515
- id: check-json
1616
- id: check-toml
1717
- id: check-added-large-files
18-
- repo: https://github.com/psf/black
19-
rev: 23.3.0
20-
hooks:
21-
- id: black
22-
- repo: https://github.com/pycqa/flake8
23-
rev: 6.0.0
24-
hooks:
25-
- id: flake8
26-
pass_filenames: true
27-
- repo: https://github.com/pycqa/isort
28-
rev: 5.12.0
29-
hooks:
30-
- id: isort
31-
- repo: https://github.com/asottile/pyupgrade
32-
rev: v3.7.0
33-
hooks:
34-
- id: pyupgrade
35-
args: [--py37-plus]
18+
3619
- repo: https://github.com/pre-commit/mirrors-prettier
37-
rev: v2.7.1
20+
rev: 50c5478ed9e10bf360335449280cf2a67f4edb7a # v2.7.1
3821
hooks:
3922
- id: prettier
4023
files: \.(html|md|yml|yaml|toml)
4124
args: [--prose-wrap=preserve]
25+
26+
- repo: https://github.com/psf/black
27+
rev: bf7a16254ec96b084a6caf3d435ec18f0f245cc7 # 23.3.0
28+
hooks:
29+
- id: black
30+
31+
- repo: https://github.com/astral-sh/ruff-pre-commit
32+
rev: 1ac904bbe451ef0b5a437d1d3b331a244c1f272c # v0.0.275
33+
hooks:
34+
- id: ruff
35+
args: [--fix, --exit-non-zero-on-fix]

lazy_loader/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def attach(package_name, submodules=None, submod_attrs=None):
6666
attr: mod for mod, attrs in submod_attrs.items() for attr in attrs
6767
}
6868

69-
__all__ = list(sorted(submodules | attr_to_modules.keys()))
69+
__all__ = sorted(submodules | attr_to_modules.keys())
7070

7171
def __getattr__(name):
7272
if name in submodules:

lazy_loader/tests/test_lazy_loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ def test_lazy_import_basics():
1515
# poor-mans pytest.raises for testing errors on attribute access
1616
try:
1717
anything_not_real.pi
18-
assert False # Should not get here
18+
raise AssertionError() # Should not get here
1919
except ModuleNotFoundError:
2020
pass
2121
assert isinstance(anything_not_real, lazy.DelayedImportErrorModule)
2222
# see if it changes for second access
2323
try:
2424
anything_not_real.pi
25-
assert False # Should not get here
25+
raise AssertionError() # Should not get here
2626
except ModuleNotFoundError:
2727
pass
2828

@@ -56,7 +56,7 @@ def test_lazy_import_nonbuiltins():
5656
if isinstance(sp, lazy.DelayedImportErrorModule):
5757
try:
5858
sp.pi
59-
assert False
59+
raise AssertionError()
6060
except ModuleNotFoundError:
6161
pass
6262

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,20 @@ Source = "https://github.com/scientific-python/lazy_loader"
3232

3333
[tool.flit.sdist]
3434
exclude = ["tests/*"]
35+
36+
[tool.ruff]
37+
line-length = 88
38+
target-version = "py37"
39+
select = [
40+
"C",
41+
"E",
42+
"F",
43+
"W",
44+
"B",
45+
"I",
46+
"UP",
47+
]
48+
ignore = ['B018']
49+
exclude = [
50+
"lazy_loader/tests/fake_pkg/__init__.pyi",
51+
]

0 commit comments

Comments
 (0)