Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ruff #59

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .flake8

This file was deleted.

34 changes: 14 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 # v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -15,27 +15,21 @@ repos:
- id: check-json
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
pass_filenames: true
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: 50c5478ed9e10bf360335449280cf2a67f4edb7a # v2.7.1
hooks:
- id: prettier
files: \.(html|md|yml|yaml|toml)
args: [--prose-wrap=preserve]

- repo: https://github.com/psf/black
rev: bf7a16254ec96b084a6caf3d435ec18f0f245cc7 # 23.3.0
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 1ac904bbe451ef0b5a437d1d3b331a244c1f272c # v0.0.275
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
2 changes: 1 addition & 1 deletion lazy_loader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def attach(package_name, submodules=None, submod_attrs=None):
attr: mod for mod, attrs in submod_attrs.items() for attr in attrs
}

__all__ = list(sorted(submodules | attr_to_modules.keys()))
__all__ = sorted(submodules | attr_to_modules.keys())

def __getattr__(name):
if name in submodules:
Expand Down
6 changes: 3 additions & 3 deletions lazy_loader/tests/test_lazy_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def test_lazy_import_basics():
# poor-mans pytest.raises for testing errors on attribute access
try:
anything_not_real.pi
assert False # Should not get here
raise AssertionError() # Should not get here
except ModuleNotFoundError:
pass
assert isinstance(anything_not_real, lazy.DelayedImportErrorModule)
# see if it changes for second access
try:
anything_not_real.pi
assert False # Should not get here
raise AssertionError() # Should not get here
except ModuleNotFoundError:
pass

Expand Down Expand Up @@ -56,7 +56,7 @@ def test_lazy_import_nonbuiltins():
if isinstance(sp, lazy.DelayedImportErrorModule):
try:
sp.pi
assert False
raise AssertionError()
except ModuleNotFoundError:
pass

Expand Down
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,20 @@ Source = "https://github.com/scientific-python/lazy_loader"

[tool.flit.sdist]
exclude = ["tests/*"]

[tool.ruff]
line-length = 88
target-version = "py37"
select = [
"C",
"E",
"F",
"W",
"B",
jarrodmillman marked this conversation as resolved.
Show resolved Hide resolved
"I",
"UP",
]
ignore = ['B018']
exclude = [
"lazy_loader/tests/fake_pkg/__init__.pyi",
]