Skip to content
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
27 changes: 5 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,18 @@ repos:
- id: rstcheck
additional_dependencies:
- tomli==2.0.1
- repo: https://github.com/asottile/pyupgrade
rev: ce40a160603ab0e7d9c627ae33d7ef3906e2d2b2 # frozen: v3.19.1
hooks:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: a4920527036bb9a3f3e6055d595849d67d0da066 # frozen: 25.1.0
hooks:
- id: black
- repo: https://github.com/adamchainz/blacken-docs
rev: 78a9dcbecf4f755f65d1f3dec556bc249d723600 # frozen: 1.19.1
hooks:
- id: blacken-docs
additional_dependencies:
- black==25.1.0
- repo: https://github.com/pycqa/isort
rev: c8ab4a5b21bac924d106e3103dd7c979fdd0f9bc # frozen: 6.0.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 12753357c00c3fb8615100354c9fdc6ab80b044d # frozen: v0.11.10
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/PyCQA/flake8
rev: 4b5e89b4b108a6c1a000c591d334a99a80d34c7b # frozen: 7.2.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-logging
- flake8-tidy-imports
- id: ruff-check
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: f40886d54c729f533f864ed6ce584e920feb0af7 # frozen: v1.15.0
hooks:
Expand Down
40 changes: 35 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,42 @@ test = [
"pytest-randomly",
]

[tool.isort]
add_imports = [
"from __future__ import annotations",
[tool.ruff]
lint.select = [
# flake8-bugbear
"B",
# flake8-comprehensions
"C4",
# pycodestyle
"E",
# Pyflakes errors
"F",
# isort
"I",
# flake8-simplify
"SIM",
# flake8-tidy-imports
"TID",
# pyupgrade
"UP",
# Pyflakes warnings
"W",
]
force_single_line = true
profile = "black"
lint.ignore = [
# flake8-bugbear opinionated rules
"B9",
# line-too-long
"E501",
# suppressible-exception
"SIM105",
# if-else-block-instead-of-if-exp
"SIM108",
]
lint.extend-safe-fixes = [
# non-pep585-annotation
"UP006",
]
lint.isort.required-imports = [ "from __future__ import annotations" ]

[tool.pyproject-fmt]
max_supported_python = "3.13"
Expand Down
14 changes: 2 additions & 12 deletions src/flake8_comprehensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,7 @@ def run(self) -> Generator[tuple[int, int, str, type[Any]]]:
and not has_star_args(node)
and not has_double_star_args(node)
and node.func.id == "dict"
):
yield (
node.lineno,
node.col_offset,
self.messages["C408"].format(type=node.func.id),
type(self),
)

elif (
) or (
num_positional_args == 0
and num_keyword_args == 0
and node.func.id in ("tuple", "list")
Expand Down Expand Up @@ -226,9 +218,7 @@ def run(self) -> Generator[tuple[int, int, str, type[Any]]]:
if reverse_flag_value is None:
remediation = " - toggle reverse argument to sorted()"
else:
remediation = " - use sorted(..., reverse={!r})".format(
not reverse_flag_value
)
remediation = f" - use sorted(..., reverse={not reverse_flag_value!r})"

msg = self.messages["C413"].format(
inner=node.args[0].func.id,
Expand Down
4 changes: 0 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ commands =
-m pytest {posargs:tests}
dependency_groups =
test

[flake8]
max-line-length = 88
extend-ignore = E203,E501