{"id":6814,"library":"pysen","title":"pysen","description":"Pysen is a Python library designed to simplify code linting and formatting by centralizing the configuration and orchestration of various tools like Black, Flake8, Isort, and Mypy. It aims to provide a unified platform for maintaining consistent coding styles across projects, reducing the burden of managing individual linter configurations. Developed by Preferred Networks, it is actively maintained with regular releases.","status":"active","version":"0.12.0","language":"en","source_language":"en","source_url":"https://github.com/pfnet/pysen.git","tags":["linting","code quality","formatter","configuration","developer-tools"],"install":[{"cmd":"pip install \"pysen[lint]\"","lang":"bash","label":"Recommended for most users (installs linters)"},{"cmd":"pip install pysen","lang":"bash","label":"Install without linter dependencies"},{"cmd":"poetry add -D pysen==0.12.0 -E lint","lang":"bash","label":"Poetry installation with lint extras"}],"dependencies":[{"reason":"Requires Python 3.10 or newer. Version 0.12.0 dropped support for Python 3.7 and added support for Python 3.12, with fixes for Python 3.14.","package":"python","optional":false},{"reason":"A code formatter, orchestrated by pysen. Users should manage its version.","package":"black","optional":true},{"reason":"A linter, orchestrated by pysen. Users should manage its version.","package":"flake8","optional":true},{"reason":"An import sorter, orchestrated by pysen. Users should manage its version.","package":"isort","optional":true},{"reason":"A static type checker, orchestrated by pysen. Users should manage its version.","package":"mypy","optional":true}],"imports":[{"note":"For programmatic access to pysen's configuration model, typically used for advanced customization or plugins.","symbol":"Config","correct":"from pysen.pyproject_model import Config"}],"quickstart":{"code":"# 1. Create a pyproject.toml or pysen.toml file in your project root:\n# pyproject.toml\n# [tool.pysen]\n# version = \"0.11\" # Specify the pysen configuration version\n#\n# [tool.pysen.lint]\n# enable_black = true\n# enable_flake8 = true\n# enable_isort = true\n# enable_mypy = true\n# mypy_preset = \"strict\"\n# line_length = 88\n# py_version = \"py310\" # Adjust to your target Python version\n#\n# [[tool.pysen.lint.mypy_targets]]\n# paths = [\".\"]\n\n# 2. Run pysen from your terminal:\n# To check for linting issues:\npysen run lint\n\n# To automatically format code (where supported by linters like black, isort):\npysen run format","lang":"bash","description":"To get started with pysen, create a `pyproject.toml` (or `pysen.toml`) file in your project's root directory and define the `[tool.pysen]` section with your desired linting configurations. Then, run `pysen run lint` to check for issues or `pysen run format` to apply automatic fixes."},"warnings":[{"fix":"Ensure you explicitly install and lock the versions of linters you use alongside pysen (e.g., `pip install black==X.Y.Z`).","message":"Pysen explicitly does not manage the versions of the underlying linting tools (e.g., black, mypy, flake8, isort). Users are expected to install and manage these dependencies separately using their preferred package manager (e.g., pipenv, poetry).","severity":"gotcha","affected_versions":"<=0.12.0"},{"fix":"Use `git add` to stage the files you want pysen to check, or set the environment variable `PYSEN_IGNORE_GIT=1` to disable this behavior and check all files.","message":"By default, pysen only checks files that are tracked in Git. Files not under Git version control will be ignored.","severity":"gotcha","affected_versions":"<=0.12.0"},{"fix":"For Mypy, you must specify the target paths using `[[tool.pysen.lint.mypy_targets]]` and any exclusions with `tool.pysen.lint.mypy_exclude` directly within your configuration.","message":"Mypy has its own mechanism for discovering files and does not honor the `tool.pysen.lint.source` option in `pyproject.toml` like other linters.","severity":"gotcha","affected_versions":"<=0.12.0"},{"fix":"Ensure file names are unique across sections by explicitly adding `tool.pysen.lint.mypy_targets` sections for different parts of your codebase.","message":"Mypy may report an error 'Source file found twice under different module names' if not configured correctly.","severity":"gotcha","affected_versions":"<=0.12.0"},{"fix":"Upgrade your Python environment to 3.10 or newer.","message":"Python 3.7 is no longer supported starting from pysen 0.12.0.","severity":"breaking","affected_versions":"0.12.0 and later"},{"fix":"Upgrade pysen to version 0.12.0 or newer if using Python 3.14.","message":"Pysen 0.12.0 includes fixes for colons that violated new `configparser` rules introduced in Python 3.14. Older versions of pysen might break when run with Python 3.14.","severity":"breaking","affected_versions":"Prior to 0.12.0 with Python 3.14"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}