Skip to content

Commit

Permalink
bring lint config and pre-commit config inline with jf-remote
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Jul 31, 2024
1 parent af82c8b commit 95ae40f
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 92 deletions.
110 changes: 42 additions & 68 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,71 +1,45 @@
default_language_version:
python: python3
exclude: '^doc/'
exclude: ^doc/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: fix-encoding-pragma
args: [--remove]
- id: end-of-file-fixer
exclude: .copier-answers.yml
- id: trailing-whitespace
- repo: https://github.com/myint/autoflake
rev: v2.0.0
hooks:
- id: autoflake
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [black]
exclude: README.md
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
entry: pflake8
files: ^src/
additional_dependencies:
- pyproject-flake8==6.0.0
- flake8-bugbear==22.12.6
- flake8-typing-imports==1.14.0
- flake8-docstrings==1.6.0
- flake8-rst-docstrings==0.3.0
- flake8-rst==0.8.0
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
files: ^src/
additional_dependencies:
- tokenize-rt==4.1.0
- types-pkg_resources==0.1.2
- types-paramiko
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
stages: [commit, commit-msg]
args: [--ignore-words-list, 'titel,statics,ba,nd,te']
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.6
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: fix-encoding-pragma
args: [--remove]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black]
exclude: README.md
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
files: ^src/
additional_dependencies:
- tokenize-rt==4.1.0
- types-paramiko
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
stages: [commit, commit-msg]
args: [--ignore-words-list, "titel,statics,ba,nd,te"]
90 changes: 66 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[build-system]
requires = ["setuptools >= 42", "versioningit ~= 1.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "qtoolkit"
Expand Down Expand Up @@ -52,8 +49,6 @@ strict = []
remote = ["fabric>=3.0.0"]
msonable = ["monty>=2022.9.9",]

[project.scripts]

[project.urls]
homepage = "https://matgenix.github.io/qtoolkit/"
repository = "https://github.com/matgenix/qtoolkit"
Expand All @@ -63,21 +58,74 @@ changelog = "https://matgenix.github.io/qtoolkit/changelog"
[tool.setuptools.package-data]
qtoolkit = ["py.typed"]

[build-system]
requires = ["setuptools >= 42", "versioningit ~= 1.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.versioningit.vcs]
method = "git"
default-tag = "0.0.1"

[tool.isort]
profile = "black"
[tool.ruff]
target-version = "py39"

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"ANN", # TODO fix all ANN errors
"ARG", # TODO fix unused method argument
"BLE001",
"C408", # Unnecessary (dict/list/tuple) call - remove call
"C901", # function too complex
"COM812", # trailing comma missing
"D",
"D205",
"DTZ", # datetime-tz-now
"E501", # TODO fix line too long
"EM", # exception message must not use f-string literal
"ERA001", # found commented out code
"FA100", # TODO fix FA errors
"FBT001",
"FBT002",
"FIX002",
"G004", # logging uses fstring
"ISC001",
"N802", # TODO maybe fix these
"PD011", # pandas-use-of-dot-values
"PERF203", # try-except-in-loop
"PGH003",
"PLR0911", # too many returns
"PLR0912", # too many branches
"PLR0913", # too many arguments
"PLR0915", # too many statements
"PLR2004", # magic value used in comparison
"PT004", # pytest-missing-fixture-name-underscore
"PT006", # pytest-parametrize-names-wrong-type
"PT013", # pytest-incorrect-pytest-import
"PTH", # prefer Pathlib to os.path
"RUF013", # implicit-optional
"S106",
"S110",
"S311",
"S324", # use of insecure hash function
"S507", # paramiko auto trust
"S602",
"SIM105", # contextlib.suppress(Exception) instead of try-except
"SLF", # private member accessed outside class
"T201", # print statement
"TD", # TODOs
"TRY003", # long message outside exception class
]
pydocstyle.convention = "numpy"
isort.known-first-party = ["qtoolkit"]
isort.split-on-trailing-comma = false

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

[tool.flake8]
max-line-length = 88
max-doc-length = 88
select = "C, E, F, W, B"
extend-ignore = "E203, W503, E501, F401, RST21"
min-python-version = "3.9.0"
docstring-convention = "numpy"
rst-roles = "class, func, ref, obj"
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"**/tests/*" = ["INP001", "S101"]

[tool.mypy]
ignore_missing_imports = true
Expand All @@ -86,13 +134,14 @@ no_strict_optional = true
[tool.pytest.ini_options]
filterwarnings = [
"ignore:.*POTCAR.*:UserWarning",
"ignore:.*magmom.*:UserWarning",
"ignore:.*is not gzipped.*:UserWarning",
"ignore:.*input structure.*:UserWarning",
"ignore:.*is not gzipped.*:UserWarning",
"ignore:.*magmom.*:UserWarning",
"ignore::DeprecationWarning",
]

[tool.coverage.run]
include = ["src/*"]
parallel = true
branch = true

Expand All @@ -108,10 +157,3 @@ exclude_lines = [
'^\s*@overload( |$)',
'# pragma: no cover',
]

[tool.autoflake]
in-place = true
remove-all-unused-imports = true
remove-unused-variables = true
ignore-init-module-imports = true
expand-star-imports = true

0 comments on commit 95ae40f

Please sign in to comment.