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

chore: move to using Ruff #22

Merged
merged 1 commit into from
Feb 22, 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
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

55 changes: 15 additions & 40 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@ ci:

repos:
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.1.0
hooks:
- id: black-jupyter

- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies: [black==22.3.0]
additional_dependencies: [black==23.1.0]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.251"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0-alpha.2"
rev: "v3.0.0-alpha.4"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -41,45 +47,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-eval
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: ["-a", "from __future__ import annotations"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.1.0
hooks:
- id: pyupgrade
args: ["--py310-plus"]

- repo: https://github.com/asottile/yesqa
rev: v1.4.0
hooks:
- id: yesqa
exclude: docs/conf.py
additional_dependencies: &flake8_dependencies
- flake8-bugbear

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
exclude: docs/conf.py
additional_dependencies: *flake8_dependencies

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v1.0.1
hooks:
- id: mypy
files: src
Expand All @@ -88,7 +63,7 @@ repos:
- click
- rich
- types-PyYAML
- tomli
- tomli;python_version<"3.11"
- markdown-it-py

- repo: https://github.com/codespell-project/codespell
Expand All @@ -98,7 +73,7 @@ repos:
args: ["-Lhist,absense"]

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.8.0.4
rev: v0.9.0.2
hooks:
- id: shellcheck

Expand Down
40 changes: 36 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true


[tool.isort]
profile = "black"


[tool.pylint]
master.py-version = "3.10"
master.ignore-paths= ["src/scikit_hep_repo_review/_version.py"]
Expand All @@ -112,3 +108,39 @@ messages_control.disable = [
"invalid-name",
"redefined-outer-name",
]


[tool.ruff]
select = [
"E", "F", "W", # flake8
"B", "B904", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"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
]
extend-ignore = [
"PLR", # Design related pylint codes
"E501", # Line too long
]
target-version = "py310"
src = ["src"]
unfixable = [
"T20", # Removes print statements
"F841", # Removes unused variables
]
exclude = []
flake8-unused-arguments.ignore-variadic-names = true
1 change: 0 additions & 1 deletion src/scikit_hep_repo_review/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
default=None,
)
def main(package: Path, output: Path | None) -> None:

console = rich.console.Console(record=True)

processed = process(package)
Expand Down
4 changes: 2 additions & 2 deletions src/scikit_hep_repo_review/ghpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def __post_init__(self) -> None:
try:
object.__setattr__(self, "_info", vals["tree"])
except KeyError:
print("Failed to find tree. Result:")
print(vals)
print("Failed to find tree. Result:") # noqa: T201
print(vals) # noqa: T201
raise

@property
Expand Down
6 changes: 5 additions & 1 deletion src/scikit_hep_repo_review/ratings/flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import configparser
import functools
import sys
from importlib.abc import Traversable
from typing import Any

import tomli as tomllib
if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib


@functools.cache
Expand Down
6 changes: 3 additions & 3 deletions src/scikit_hep_repo_review/ratings/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PY003(General):
@staticmethod
def check(package: Traversable) -> bool:
"Projects must have a license"
return len(list(p for p in package.iterdir() if "LICENSE" in p.name)) > 0
return len([p for p in package.iterdir() if "LICENSE" in p.name]) > 0


class PY004(General):
Expand All @@ -49,7 +49,7 @@ class PY004(General):
@staticmethod
def check(package: Traversable) -> bool:
"Projects must have documentation in a folder called docs (disable if not applicable)"
return len(list(p for p in package.iterdir() if "doc" in p.name)) > 0
return len([p for p in package.iterdir() if "doc" in p.name]) > 0


class PY005(General):
Expand All @@ -58,7 +58,7 @@ class PY005(General):
@staticmethod
def check(package: Traversable) -> bool:
"Projects must have a folder called tests"
return len(list(p for p in package.iterdir() if "test" in p.name)) > 0
return len([p for p in package.iterdir() if "test" in p.name]) > 0


class PY006(General):
Expand Down
6 changes: 5 additions & 1 deletion src/scikit_hep_repo_review/ratings/pyproject.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from __future__ import annotations

import functools
import sys
from importlib.abc import Traversable
from typing import Any

import tomli as tomllib
if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib


@functools.cache
Expand Down
2 changes: 1 addition & 1 deletion tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_version():
assert m.__version__


@pytest.mark.skip
@pytest.mark.skip()
def test_pyodide():
package = GHPath(repo="scikit-hep/repo-review", branch="main")
results = process(package)
Expand Down