Issue: Misalignment between pre-commit and CI linting stacks

Edgar Rivera
2026-03-27T10:37:10Z

## Problem

Pre-commit was upgraded to flake8 7.3.0 + wemake-python-styleguide 1.5.0 on Python 3.12, but the CI image (Dockerfile.tests / requirements-tests.in) is still on flake8 4.0.1 + wps 0.17.0
on Python 3.11. Developers can get different linting results locally vs CI.

The upgrade is coupled -- flake8 4.0.1 crashes on Python 3.12 due to an importlib.metadata API change, so bumping Python forces bumping flake8 + all plugins together.

| | Pre-commit | CI |
|---|---|---|
| Python | 3.12 | 3.11 |
| flake8 | 7.3.0 | 4.0.1 |
| wemake-python-styleguide | 1.5.0 | 0.17.0 |
| flake8-async | 25.7.1 | 22.11.14 |

## Issues found when testing the full upgrade

1. **flake8-async** -- the new version (25.7.1) adds ~160 trio-specific rules (ASYNC910, ASYNC124, etc.) that do not apply to our FastAPI/asyncio codebase. Additionally, flake8 7.x
rejects error codes longer than 3 letters, so they cannot even be ignored in setup.cfg. The plugin would need to be removed or pinned to the old version.

2. **Invalid escape sequences** -- Python 3.12 flags 2 files with unescaped strings as SyntaxWarning (will become hard errors in a future Python version):
- app/api/routes/v2/master_data/api.py:26
- app/dev/search/redis_analysis_type_ids_fetcher.py:140

3. **3 new WPS rules** surfaced by wps 1.5.0 that the old version did not check:
- WPS476 -- await in for loop (9 hits)
- WPS504 -- negated condition (6 hits)
- WPS365 -- simplifiable match statement (1 hit)

4. **Pre-existing violations** -- both stacks report ~65 violations in the same files.