Skip to content

Update ruff config #123

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

Merged
merged 3 commits into from
Jul 5, 2024
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
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1f423a22d8b27926da7d7b7393c833da0f3714a4
8 changes: 2 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ repos:
files: \.(html|md|yml|yaml|toml)
args: [--prose-wrap=preserve]

- repo: https://github.com/psf/black
rev: 3702ba224ecffbcec30af640c149f231d90aebdb # frozen: 24.4.2
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 1dc9eb131c2ea4816c708e4d85820d2cc8542683 # frozen: v0.5.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]
- id: ruff-format
6 changes: 2 additions & 4 deletions lazy_loader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def attach(package_name, submodules=None, submod_attrs=None):
The typical way to call this function, replacing the above imports, is::

__getattr__, __dir__, __all__ = lazy.attach(
__name__,
['mysubmodule', 'anothersubmodule'],
{'foo': ['someattr']}
__name__, ["mysubmodule", "anothersubmodule"], {"foo": ["someattr"]}
)

Parameters
Expand Down Expand Up @@ -162,7 +160,7 @@ def myfunc():
fullname : str
The full name of the module or submodule to import. For example::

sp = lazy.load('scipy') # import scipy as sp
sp = lazy.load("scipy") # import scipy as sp

require : str
A dependency requirement as defined in PEP-508. For example::
Expand Down
1 change: 0 additions & 1 deletion lazy_loader/tests/fake_pkg/some_func.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
def some_func():
"""Function with same name as submodule."""
pass
3 changes: 2 additions & 1 deletion lazy_loader/tests/test_lazy_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,6 @@ def test_parallel_load():
[
sys.executable,
os.path.join(os.path.dirname(__file__), "import_np_parallel.py"),
]
],
check=True,
)
50 changes: 39 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,55 @@ dev = ["changelist == 0.5"]
Home = "https://scientific-python.org/specs/spec-0001/"
Source = "https://github.com/scientific-python/lazy-loader"


[tool.changelist]
ignored_user_logins = ["dependabot[bot]", "pre-commit-ci[bot]", "web-flow"]

[tool.setuptools.dynamic.version]
attr = 'lazy_loader.__version__'

[tool.ruff]
line-length = 88
exclude = [
"lazy_loader/tests/fake_pkg/__init__.pyi",
]

[tool.ruff.lint]
select = [
"C",
"E",
"F",
"W",
"B",
"I",
"UP",
extend-select = [
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
# "PTH", # flake8-use-pathlib
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
"NPY", # NumPy specific rules
"PD", # pandas-vet
"FURB", # refurb
"PYI", # flake8-pyi
]
ignore = [
"PLR09", # Too many <...>
"PLR2004", # Magic value used in comparison
"ISC001", # Conflicts with formatter
"B018", # Found useless expression
"B028", # No explicit `stacklevel` keyword argument found
"PT011", # `pytest.raises(ValueError)` is too broad
"EM102", # Exception must not use an f-string literal
"EM101", # Exception must not use a string literal
"RET505", # Unnecessary `elif` after `return` statement
"SIM108", # Use ternary operator
]
ignore = ["B018", "B028"]

[tool.ruff.format]
docstring-code-format = true
Loading