{"id":6426,"library":"pycln","title":"Pycln - Unused Import Cleaner","description":"Pycln is a fast and efficient code formatter for finding and removing unused import statements in Python code. It helps to keep your codebase clean and reduce unnecessary dependencies. The current version is 2.6.0 and it maintains a relatively frequent release cadence, often aligning with Python version updates and bug fixes.","status":"active","version":"2.6.0","language":"en","source_language":"en","source_url":"https://github.com/hadialqattan/pycln","tags":["formatter","linter","code-quality","imports","cli"],"install":[{"cmd":"pip install pycln","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core dependency for AST parsing and manipulation.","package":"libcst","optional":false},{"reason":"Used for gitignore-style path filtering.","package":"pathspec","optional":false}],"imports":[{"note":"Pycln is primarily a command-line interface (CLI) tool. While you can import and call `main` programmatically, the most common and recommended usage is via the `pycln` command in your terminal.","symbol":"main","correct":"from pycln.main import main"}],"quickstart":{"code":"# To analyze current directory and remove unused imports:\npycln . \n\n# To check for unused imports without modifying files:\npycln --check . \n\n# To include specific files or directories:\npycln my_module.py my_package/","lang":"bash","description":"The primary way to use Pycln is through its command-line interface. Run `pycln .` in your project's root directory to scan and remove unused imports. Use `--check` to preview changes, or `--diff` to see a diff."},"warnings":[{"fix":"Upgrade to Python 3.9 or newer, or pin Pycln to `<2.6.0`.","message":"Pycln dropped support for Python 3.8 in version 2.6.0. Users on Python 3.8 or older must use Pycln v2.5.0 or earlier.","severity":"breaking","affected_versions":">=2.6.0"},{"fix":"Upgrade to Python 3.8 or newer, or pin Pycln to `<2.5.0`.","message":"Pycln dropped support for Python 3.7 in version 2.5.0. Users on Python 3.7 or older must use Pycln v2.4.0 or earlier.","severity":"breaking","affected_versions":">=2.5.0"},{"fix":"Upgrade to Pycln v2.6.0 or newer for full Python 3.14 compatibility.","message":"When running Pycln with Python 3.14 (or early development versions), versions prior to 2.6.0 might fail due to changes in Python's AST (specifically, `ast.Str` being removed).","severity":"gotcha","affected_versions":"<2.6.0"},{"fix":"Upgrade to Pycln v2.5.0 or newer. Ensure your `pyproject.toml` is correctly formatted and accessible.","message":"In versions prior to 2.5.0, Pycln could encounter 'missing pyproject.toml' errors when reading configuration, even if the file existed.","severity":"gotcha","affected_versions":"<2.5.0"},{"fix":"Upgrade to Pycln v2.1.6 or newer. If issues persist, consider using a `--skip` option for specific files or imports that rely heavily on implicit behavior.","message":"Implicit imports (e.g., `from package import module` where `module` is not directly used but its side effects are needed) were sometimes misparsed and considered unused in Pycln versions prior to 2.1.6.","severity":"gotcha","affected_versions":"<2.1.6"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}