Skip to content

Commit 70b3671

Browse files
committed
[chore:validator] Add func skip f-string for LiteralSelector
1 parent 7d570db commit 70b3671

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343

4444
- name: Install dependencies from lockfile
4545
run:
46-
uv pip sync --strict uv.lock && uv pip install -e ".[dev]"
46+
uv pip install -e ".[dev]"
4747

4848
- name: Run linting and tests
4949
run: |

src/code_validator/output.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ def __init__(self, logger: logging.Logger, *, is_silent: bool = False):
6565
self._stdout = sys.stdout
6666

6767
def print(
68-
self,
69-
message: str,
70-
*,
71-
level: LogLevel | Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = LogLevel.INFO,
68+
self,
69+
message: str,
70+
*,
71+
level: LogLevel | Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = LogLevel.INFO,
7272
) -> None:
7373
"""Prints a message to stdout and logs it simultaneously.
7474

src/code_validator/rules_library/selector_nodes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,13 @@ def select(self, tree: ast.Module) -> list[ast.AST]:
271271
if not isinstance(node.value, expected_py_types):
272272
continue
273273

274-
# --- ЛОГИКА ИГНОРИРОВАНИЯ ДОКСТРИНГОВ ---
275-
# Если у узла есть родитель и этот родитель - Expr,
276-
# то велика вероятность, что это докстринг или "висячая" строка.
277-
# Настоящие "магические" строки обычно являются аргументами функций
278-
# или значениями в присваиваниях.
274+
# Пропускаем докстринги
279275
if hasattr(node, "parent") and isinstance(node.parent, ast.Expr):
280-
continue # Пропускаем этот узел, считая его докстрингом.
276+
continue
277+
278+
# Пропускаем f-строки
279+
if hasattr(node, "parent") and isinstance(node.parent, ast.JoinedStr):
280+
continue
281281

282282
found_nodes.append(node)
283283

tests/test_validator.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,16 @@ def test_run_with_malformed_rule_raises_error(self):
9393

9494
def test_linter_rule_passes_for_valid_code(self):
9595
"""Tests that CheckLinterRule passes for clean code."""
96-
rules = {"validation_rules": [{"rule_id": 1, "type": "check_linter_pep8", "message": "PEP8 fail", "params": {
97-
"ignore": ["F401", "E302", "E305", "E261"]
98-
}}]}
96+
rules = {
97+
"validation_rules": [
98+
{
99+
"rule_id": 1,
100+
"type": "check_linter_pep8",
101+
"message": "PEP8 fail",
102+
"params": {"ignore": ["F401", "E302", "E305", "E261"]},
103+
}
104+
]
105+
}
99106
rules_path = FIXTURES_DIR / "temp_linter_rules.json"
100107
with open(rules_path, "w", encoding="utf-8") as f:
101108
# noinspection PyTypeChecker

0 commit comments

Comments
 (0)