diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5ea94f16..bb124bf0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,7 +59,11 @@ repos: hooks: - id: yesqa - - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.226 hooks: - - id: flake8 + - id: ruff + args: + - "--fix" + # Respect `exclude` and `extend-exclude` settings. + - "--force-exclude" diff --git a/pyproject.toml b/pyproject.toml index 03618c0c..2dc1cb88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,100 @@ +[metadata] +license_file = "LICENSE" +description-file = "README.md" + [build-system] requires = [ "setuptools", "wheel", ] +[tool.check-manifest] +ignore = [ + "*.yml", + ".github", + ".github/*" +] + +[tool.pytest.ini_options] +norecursedirs = [ + ".git", + ".github", + "dist", + "build", + "docs", +] + +addopts = [ + "--strict-markers", + "--doctest-modules", + "--durations=25", + "--color=yes", + "--disable-pytest-warnings", +] +filterwarnings = ["error::FutureWarning", "error::DeprecationWarning"] +xfail_strict = true + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "pass", +] + +[tool.coverage.run] +parallel = true +concurrency = "thread" +relative_files = true + [tool.black] # https://github.com/psf/black line-length = 120 exclude = "(.eggs|.git|.hg|.mypy_cache|.venv|_build|buck-out|build|dist)" + +[tool.isort] +known_first_party = [ + "lightning_utilities", + "tests" +] +skip_glob = [] +profile = "black" +line_length = 120 +order_by_type = false +multi_line_output = 3 +include_trailing_comma = true + +[tool.mypy] +files = [ + "src/lightning_utilities", +] +disallow_untyped_defs = true +ignore_missing_imports = true + +[tool.ruff] + line-length = 120 + select = [ + "E", "W", # see: https://pypi.org/project/pycodestyle + "F", # see: https://pypi.org/project/pyflakes + ] + ignore = [ + "E731", + ] + exclude = [ + ".eggs", + ".git", + ".mypy_cache", + ".ruff_cache", + "__pypackages__", + "_build", + "build", + "dist", + "docs" + ] + ignore-init-module-imports = true + + # [tool.ruff.per-file-ignores] + # "setup.py" = ["D100", "SIM115"] + # "__about__.py" = ["D100"] + # "__init__.py" = ["D100"] + + [tool.ruff.mccabe] + max-complexity = 10 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index cc49f4f9..00000000 --- a/setup.cfg +++ /dev/null @@ -1,67 +0,0 @@ -[tool:pytest] -norecursedirs = - .git - dist - build -addopts = - --strict-markers - --doctest-modules - --durations=25 - --color=yes - --disable-pytest-warnings -filterwarnings = - error::FutureWarning - error::DeprecationWarning -xfail_strict = true - -[coverage:report] -exclude_lines = - pragma: no-cover - pass - -[flake8] -max-line-length = 120 -exclude = .tox,*.egg,build,temp -select = E,W,F -doctests = True -verbose = 2 -# https://pep8.readthedocs.io/en/latest/intro.html#error-codes -format = pylint -ignore = - # Ignore "Do not assign a lambda expression, use a def" - E731 - # Ignore "Line break occurred before a binary operator" - W503 - # Ignore "whitespace before ':'" - E203 - -# setup.cfg or tox.ini -[check-manifest] -ignore = - *.yml - .github - .github/* - -[metadata] -license_files = LICENSE -description_file = README.md -# long_description = file:README.md -# long_description_content_type = text/markdown - -[isort] -known_first_party = - lightning_utilities - tests -line_length = 120 -order_by_type = False -# 3 - Vertical Hanging Indent -multi_line_output = 3 -include_trailing_comma = True - -[mypy] -# Typing tests is low priority, but enabling type checking on the -# untyped test functions (using `--check-untyped-defs`) is still -# high-value because it helps test the typing. -files = src/lightning_utilities -disallow_untyped_defs = True -ignore_missing_imports = True diff --git a/src/lightning_utilities/core/imports.py b/src/lightning_utilities/core/imports.py index 0e13b1b9..ee980b9f 100644 --- a/src/lightning_utilities/core/imports.py +++ b/src/lightning_utilities/core/imports.py @@ -4,8 +4,6 @@ import functools import importlib -import operator -import os import warnings from functools import lru_cache from importlib.util import find_spec