Registry / testing / flake8-2020

flake8-2020

JSON →
library1.8.1pypypiunverified

A flake8 plugin that checks for misuse of `sys.version` or `sys.version_info` to detect code that will break on Python 4. Current version: 1.8.1 (requires Python >=3.8). Released irregularly; last release Dec 2024.

pip install flake8-2020
INSTALL
IMPORT
SIG · FLAKE8-2020
F
flake8-2020
testingpythonv1.8.1
Install
1.8s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.8.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

flake8-2020
Installed as a plugin; no explicit import needed
flae8 automatically discovers plugins; do not import flake8_2020 in your code.

The plugin is automatically discovered by flake8. Run 'flake8 yourfile.py' to check for sys.version misuse.

# Run flake8 with the plugin enabled (flake8 discovers it automatically) # The plugin checks for Python 4 compatibility issues import sys print(sys.version_info[0]) # This will trigger YTT103 (sys.version_info used as tuple) print(sys.version_info.major) # Correct usage
Debug
Known issues
gotchaThe plugin is automatically enabled when installed; no configuration needed. However, it only works if flake8 is run on the file.
fix
Run flake8 from the command line or integrate into your pre-commit hooks.
affects: all
deprecatedThe deprecated YTT301 (sys.version[0:3] used) and YTT302 (sys.version[2] used) are still emitted but may be removed in future versions.
fix
Use sys.version_info.major instead of string slicing.
affects: 1.7.0+
breakingIn version 1.8.0, the minimum Python version was raised to 3.8, dropping Python 3.6 and 3.7 support.
fix
Upgrade to Python 3.8 or later.
affects: 1.8.0+
Upgrade
Version history
1.8.1latest on PyPI · released Jun 10, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
flake8-2020 — pip install flake8-2020 · libregistry