Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit suggestions (#2620)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit suggestions

updates:
- [github.com/codespell-project/codespell: v2.2.6 → v2.3.0](codespell-project/codespell@v2.2.6...v2.3.0)
- [github.com/crate-ci/typos: v1.20.7 → v1.22.9](crate-ci/typos@v1.20.7...v1.22.9)
- [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.8](pre-commit/mirrors-prettier@v3.1.0...v4.0.0-alpha.8)
- [github.com/astral-sh/ruff-pre-commit: v0.3.5 → v0.5.0](astral-sh/ruff-pre-commit@v0.3.5...v0.5.0)
- [github.com/tox-dev/pyproject-fmt: 1.7.0 → 2.1.3](tox-dev/pyproject-fmt@1.7.0...2.1.3)
- [github.com/abravalheri/validate-pyproject: v0.16 → v0.18](abravalheri/validate-pyproject@v0.16...v0.18)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

* fix

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
Co-authored-by: Jirka <jirka.borovec@seznam.cz>
  • Loading branch information
3 people committed Jul 3, 2024
1 parent 95b8d9d commit fe65dde
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
level of experience, education, socioeconomic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ repos:
- id: detect-private-key

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies: [tomli]
args: ["--write-changes"]
exclude: pyproject.toml

- repo: https://github.com/crate-ci/typos
rev: v1.20.7
rev: v1.22.9
hooks:
- id: typos
# empty to do not write fixes
Expand Down Expand Up @@ -112,7 +112,7 @@ repos:
- id: text-unicode-replacement-char

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.5.0
hooks:
# try to fix what is possible
- id: ruff
Expand All @@ -123,11 +123,11 @@ repos:
- id: ruff

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.7.0
rev: 2.1.3
hooks:
- id: pyproject-fmt
additional_dependencies: [tox]
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.16
rev: v0.18
hooks:
- id: validate-pyproject
187 changes: 100 additions & 87 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,82 +8,80 @@ requires = [
target-version = "py38"
line-length = 120

[tool.ruff.format]
preview = true

[tool.ruff.lint]
select = [
"E",
"W", # see: https://pypi.org/project/pycodestyle
"F", # see: https://pypi.org/project/pyflakes
"I", #see: https://pypi.org/project/isort/
"D", # see: https://pypi.org/project/pydocstyle
"N", # see: https://pypi.org/project/pep8-naming
"S", # see: https://pypi.org/project/flake8-bandit
"UP", # see: https://docs.astral.sh/ruff/rules/#pyupgrade-up
]
extend-select = [
"A", # see: https://pypi.org/project/flake8-builtins
"B", # see: https://pypi.org/project/flake8-bugbear
"C4", # see: https://pypi.org/project/flake8-comprehensions
"PT", # see: https://pypi.org/project/flake8-pytest-style
"RET", # see: https://pypi.org/project/flake8-return
"SIM", # see: https://pypi.org/project/flake8-simplify
"YTT", # see: https://pypi.org/project/flake8-2020
"ANN", # see: https://pypi.org/project/flake8-annotations
"TID", # see: https://pypi.org/project/flake8-tidy-imports/
"T10", # see: https://pypi.org/project/flake8-debugger
"Q", # see: https://pypi.org/project/flake8-quotes
"RUF", # Ruff-specific rules
"EXE", # see: https://pypi.org/project/flake8-executable
"ISC", # see: https://pypi.org/project/flake8-implicit-str-concat
"PIE", # see: https://pypi.org/project/flake8-pie
"PLE", # see: https://pypi.org/project/pylint/
"PERF", # see: https://pypi.org/project/perflint/
"PYI", # see: https://pypi.org/project/flake8-pyi/
]
ignore = [
"E731", # Do not assign a lambda expression, use a def
"D100", # todo: Missing docstring in public module
"D104", # todo: Missing docstring in public package
"D107", # Missing docstring in `__init__`
"ANN101", # Missing type annotation for `self` in method
]
ignore-init-module-imports = true
unfixable = ["F401"]

[tool.ruff.lint.per-file-ignores]
"setup.py" = ["ANN202", "ANN401"]
"docs/source/conf.py" = ["A001", "D103"]
"examples/*" = [
"E501", # Line too long (XXX > 120)
"D205", # 1 blank line required between summary line and description
"D212", # [*] Multi-line docstring summary should start at the first line
"D415", # First line should end with a period, question mark, or exclamation point
]
"src/**" = [
"ANN401",
"S310", # todo: Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected.
]
"tests/**" = [
"ANN001",
"ANN201",
"ANN202",
"ANN401",
"S101",
"S301", # todo: `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
]

[tool.ruff.lint.pydocstyle]
# Use Google-style docstrings.
convention = "google"

#[tool.ruff.pycodestyle]
#ignore-overlong-task-comments = true

[tool.ruff.lint.mccabe]
format.preview = true
lint.select = [
"D", # see: https://pypi.org/project/pydocstyle
"E",
"F", # see: https://pypi.org/project/pyflakes
"I", #see: https://pypi.org/project/isort/
"N", # see: https://pypi.org/project/pep8-naming
"S", # see: https://pypi.org/project/flake8-bandit
"UP", # see: https://docs.astral.sh/ruff/rules/#pyupgrade-up
"W", # see: https://pypi.org/project/pycodestyle
]
lint.extend-select = [
"A", # see: https://pypi.org/project/flake8-builtins
"ANN", # see: https://pypi.org/project/flake8-annotations
"B", # see: https://pypi.org/project/flake8-bugbear
"C4", # see: https://pypi.org/project/flake8-comprehensions
"EXE", # see: https://pypi.org/project/flake8-executable
"ISC", # see: https://pypi.org/project/flake8-implicit-str-concat
"PERF", # see: https://pypi.org/project/perflint/
"PIE", # see: https://pypi.org/project/flake8-pie
"PLE", # see: https://pypi.org/project/pylint/
"PT", # see: https://pypi.org/project/flake8-pytest-style
"PYI", # see: https://pypi.org/project/flake8-pyi/
"Q", # see: https://pypi.org/project/flake8-quotes
"RET", # see: https://pypi.org/project/flake8-return
"RUF", # Ruff-specific rules
"SIM", # see: https://pypi.org/project/flake8-simplify
"T10", # see: https://pypi.org/project/flake8-debugger
"TID", # see: https://pypi.org/project/flake8-tidy-imports/
"YTT", # see: https://pypi.org/project/flake8-2020
]
lint.ignore = [
"ANN101", # Missing type annotation for `self` in method
"D100", # todo: Missing docstring in public module
"D104", # todo: Missing docstring in public package
"D107", # Missing docstring in `__init__`
"E731", # Do not assign a lambda expression, use a def
]
lint.per-file-ignores."docs/source/conf.py" = [
"A001",
"D103",
]
lint.per-file-ignores."examples/*" = [
"D205", # 1 blank line required between summary line and description
"D212", # [*] Multi-line docstring summary should start at the first line
"D415", # First line should end with a period, question mark, or exclamation point
"E501", # Line too long (XXX > 120)
]
lint.per-file-ignores."setup.py" = [
"ANN202",
"ANN401",
]
lint.per-file-ignores."src/**" = [
"ANN401",
"S310", # todo: Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected.
]
lint.per-file-ignores."tests/**" = [
"ANN001",
"ANN201",
"ANN202",
"ANN401",
"S101",
"S301", # todo: `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
]
lint.unfixable = [
"F401",
]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
lint.mccabe.max-complexity = 10
# Use Google-style docstrings.
lint.pydocstyle.convention = "google"
lint.ignore-init-module-imports = true

[tool.codespell]
#skip = '*.py'
Expand All @@ -109,36 +107,51 @@ wrap-descriptions = 120
blank = true

[tool.check-manifest]
ignore = ["*.yml", ".github", ".github/*"]
ignore = [
"*.yml",
".github",
".github/*",
]

[tool.pytest.ini_options]
norecursedirs = [".git", ".github", "dist", "build", "docs"]
norecursedirs = [
".git",
".github",
"dist",
"build",
"docs",
]
addopts = [
"--strict-markers",
"--doctest-modules",
"--doctest-plus",
"--color=yes",
"--disable-pytest-warnings",
"--strict-markers",
"--doctest-modules",
"--doctest-plus",
"--color=yes",
"--disable-pytest-warnings",
]
markers = [
"DDP: mark a test as Distributed Data Parallel",
"DDP: mark a test as Distributed Data Parallel",
]
filterwarnings = [
"ignore::FutureWarning",
"default:::torchmetrics",
"ignore::FutureWarning",
"default:::torchmetrics",
]
xfail_strict = true
junit_duration_report = "call"

[tool.coverage.report]
exclude_lines = ["pragma: no cover", "pass"]
exclude_lines = [
"pragma: no cover",
"pass",
]
[tool.coverage.run]
parallel = true
concurrency = "thread"
relative_files = true

[tool.mypy]
files = ["src/torchmetrics"]
files = [
"src/torchmetrics",
]
install_types = "True"
non_interactive = "True"
disallow_untyped_defs = "True"
Expand All @@ -155,8 +168,8 @@ warn_no_return = "False"

[tool.typos.default]
extend-ignore-identifiers-re = [
# *sigh* this just isn't worth the cost of fixing
"AttributeID.*Supress.*",
# *sigh* this just isn't worth the cost of fixing
"AttributeID.*Supress.*",
]

[tool.typos.default.extend-identifiers]
Expand Down
5 changes: 1 addition & 4 deletions src/torchmetrics/functional/text/ter.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ def _handle_corner_cases_during_shifting(
return True

# don't try to shift within the subsequence
if pred_start <= alignments[target_start] < pred_start + length:
return True

return False
return pred_start <= alignments[target_start] < pred_start + length


def _perform_shift(words: List[str], start: int, length: int, target: int) -> List[str]:
Expand Down
4 changes: 1 addition & 3 deletions src/torchmetrics/utilities/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@


def _check_for_empty_tensors(preds: Tensor, target: Tensor) -> bool:
if preds.numel() == target.numel() == 0:
return True
return False
return preds.numel() == target.numel() == 0


def _check_same_shape(preds: Tensor, target: Tensor) -> None:
Expand Down

0 comments on commit fe65dde

Please sign in to comment.