{"id":23729,"library":"flake8-2020","title":"flake8-2020","description":"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.","status":"active","version":"1.8.1","language":"python","source_language":"en","source_url":"https://github.com/asottile/flake8-2020","tags":["flake8","plugin","sys.version","sys.version_info","python4","linting"],"install":[{"cmd":"pip install flake8-2020","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"flae8 automatically discovers plugins; do not import flake8_2020 in your code.","wrong":"","symbol":"flake8-2020","correct":"Installed as a plugin; no explicit import needed"}],"quickstart":{"code":"# Run flake8 with the plugin enabled (flake8 discovers it automatically)\n# The plugin checks for Python 4 compatibility issues\nimport sys\nprint(sys.version_info[0])  # This will trigger YTT103 (sys.version_info used as tuple)\nprint(sys.version_info.major)  # Correct usage","lang":"python","description":"The plugin is automatically discovered by flake8. Run 'flake8 yourfile.py' to check for sys.version misuse."},"warnings":[{"fix":"Run flake8 from the command line or integrate into your pre-commit hooks.","message":"The plugin is automatically enabled when installed; no configuration needed. However, it only works if flake8 is run on the file.","severity":"gotcha","affected_versions":"all"},{"fix":"Use sys.version_info.major instead of string slicing.","message":"The deprecated YTT301 (sys.version[0:3] used) and YTT302 (sys.version[2] used) are still emitted but may be removed in future versions.","severity":"deprecated","affected_versions":"1.7.0+"},{"fix":"Upgrade to Python 3.8 or later.","message":"In version 1.8.0, the minimum Python version was raised to 3.8, dropping Python 3.6 and 3.7 support.","severity":"breaking","affected_versions":"1.8.0+"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Do not import flake8_2020 in your code. The plugin is automatically discovered by flake8. Run 'flake8 yourfile.py'.","cause":"Trying to import the plugin directly in Python code instead of using flake8.","error":"No module named 'flake8_2020'"},{"fix":"Do not define any variable or function named YTT*, as those are reserved for plugin error codes.","cause":"The user manually defined YTT103 as a variable or function, conflicting with flake8-2020's warning codes.","error":"flake8 says 'undefined name YTT103' when running"},{"fix":"Ensure flake8-2020 is installed in the same environment as flake8. Run 'pip show flake8-2020' to verify.","cause":"The file is not being linted by flake8, or the plugin is not installed correctly.","error":"flake8 does not detect sys.version_info issues"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}