SHORTLIST20
中文
Englishالعربية中文日本語한국어EspañolFrançaisहिन्दी
编程

热门 Python 代码检查、格式化与类型检查工具

Ruff, Black, mypy, Pyright, pre-commit and other tools that check Python code before it runs

更新于 · GitHub stars (stars)

为什么是这20个

Ranked by GitHub stars: how many developers bookmarked the project. Stars measure attention, not quality, so each row also shows forks, licence, the last push and the section of the community list it sits in. Formatters (Black, isort), linters (Ruff, pylint, flake8, Bandit for security), type checkers (mypy, Pyright, ty, Pyrefly) and refactoring tools do different jobs and share one list, so check the 'listed under' column. Ruff does the work of several older tools at once, which is part of why it leads; newer type checkers (ty, Pyrefly) are young and still gathering stars. The community list holds fewer than 20 of these tools, so the list is shorter than 20.

这份清单有用吗?
  1. 1

    astral-sh/ruff

    An extremely fast Python linter and code formatter, written in Rust.

    51,468 stars 2,773 forkslast push 2026-11-23RustMIT

    也在: #3 Rust developer tools#1 Rust linters and code quality tools, ranked by GitHub stars

  2. 2

    black

    The uncompromising Python code formatter.

    42,210 stars 3,092 forkslast push 2026-11-20PythonMIT

  3. 3

    mypy

    A static type checker for Python.

    20,736 stars 3,492 forkslast push 2026-11-20PythonNOASSERTION

  4. 4

    ty

    An extremely fast Python type checker and language server.

    20,138 stars 350 forkslast push 2026-11-22PythonMIT

  5. 5

    pyright

    Full-featured static type checker for Python from Microsoft, the engine behind Pylance.

    15,757 stars 1,856 forkslast push 2026-11-20PythonNOASSERTION

  6. 6

    pre-commit

    A framework for managing and maintaining multi-language pre-commit hooks.

    15,712 stars 1,116 forkslast push 2026-11-09PythonMIT

  7. 7

    bandit

    A tool designed to find common security issues in Python code.

    8,401 stars 894 forkslast push 2026-11-09PythonApache-2.0

  8. 8

    isort

    A Python utility / library to sort imports.

    6,965 stars 844 forkslast push 2026-11-16PythonMIT

  9. 9

    pylint

    A fully customizable source code analyzer.

    5,749 stars 1,461 forkslast push 2026-11-20PythonGPL-2.0

  10. 10

    vulture

    A tool for finding and analyzing dead Python code.

    5,005 stars 226 forkslast push 2026-11-16PythonMIT

  11. 11

    flake8

    A wrapper around, and McCabe.

    3,837 stars 452 forkslast push 2026-11-04PythonNOASSERTION

  12. 12

    basedpyright

    A pyright fork with stricter defaults and Pylance features in its language server.

    3,655 stars 139 forkslast push 2026-11-10TypeScriptNOASSERTION

  13. 13

    rope

    Rope is a Python refactoring library.

    2,247 stars 212 forkslast push 2026-11-16PythonLGPL-3.0

  14. 14

    prospector

    A tool to analyze Python code.

    2,082 stars 184 forkslast push 2026-11-18PythonGPL-2.0

  15. 15

    complexipy

    Cognitive complexity analysis for Python code, written in Rust.

    924 stars 30 forkslast push 2026-11-19RustMIT

并排比较

LicencePlatformsWhat it doesPython versionsAsync supportType hintsPlugins and ecosystemBest for
astral-sh/ruffMIT License–––––––
blackMIT LicenseCross-platform (Linux, macOS, Windows)Uncompromising, deterministic, and opinionated Python code formatterRuns on Python 3.10+; formats Python 3.3 to 3.15Formats async def, await expressions, and asynchronous comprehensionsFormats type annotations and type stub (.pyi) filesEditor plugins, pre-commit integration, blackd HTTP daemon, and GitHub ActionsEnforcing uniform, hands-off code style across teams and projects
mypyMIT LicenseCross-platform (Linux, macOS, Windows)Static type checker for Python based on type annotationsRuns on Python 3.8+; checks Python 3.8 to 3.15Type checks coroutines, async generators, awaitables, and asyncio modulesComprehensive support for PEP 484, PEP 526, and modern typing standardsCustom plugin system, typeshed stubs, dmypy daemon, and pre-commit hooksStandard static type checking and gradual typing in Python codebases
tyMIT License––Python 3.8 to 3.15 (officially targets Python 3.10+)––––
pyrightMIT LicenseCross-platform (Linux, macOS, Windows via Node.js)Fast, full-featured static type checker and Python language serverConfigurable from Python 3.0 up to 3.14+Type checks async functions, coroutine returns, await expressions, and generatorsComprehensive support for PEP typing specifications and strict type validationPowers Pylance in VS Code, CLI npm package, and LSPFast, real-time type checking and language server features in IDEs
pre-commitMIT LicenseCross-platform (Linux, macOS, Windows)Framework for managing and running multi-language git hook scriptsRuns on Python 3.9+Not applicable; runs configured external hooks synchronously or in parallelDoes not check types directly; runs external type checking hooksEcosystem of hundreds of community hooks across Python, JS, RustAutomating pre-commit code verification, formatting, and linting in Git
banditApache-2.0 LicenseCross-platform (Linux, macOS, Windows)Security linter designed to find common security issues in PythonPython 3.8+Scans async function AST nodes for security vulnerabilitiesIgnores type hints; focuses strictly on security flaw AST patternsPlugin architecture for custom security checks; integrates with pre-commit, CIAutomated security vulnerability scanning and static application security testing (SAST)
isortMIT LicenseCross-platform (Linux, macOS, Windows)Utility to sort, format, and section Python import statements automaticallyPython 3.8+Sorts and formats imports regardless of synchronous or asynchronous module usageSupports sorting typing imports and TYPE_CHECKING conditional import blocksIntegrations with Flake8, Black, pre-commit, VS Code, and Sublime TextAutomating standardized, deterministic sorting of Python imports across files
pylintGPL-2.0-or-laterCross-platform (Linux, macOS, Windows)Highly customizable static code analyzer checking bugs, style, and conventionsPython 3.9+Checks async functions, await expressions, async context managers, and iteratorsAnalyzes type annotations and uses AST inference via Astroid libraryExtensible plugin architecture (e.g., pylint-django, pylint-celery) and editor integrationsComprehensive, highly customizable code analysis and enforcing strict coding guidelines
vultureMIT LicenseCross-platform (Linux, macOS, Windows)Finds and reports unused and dead code in Python programsPython 3.8+Detects unused async function definitions, coroutines, and async methodsParses variable and attribute annotations to avoid flagging them as unusedPre-commit hook, Flake8 plugin integration, and whitelist generation toolsDetecting and pruning unused functions, classes, and variables from codebases
flake8MIT LicenseCross-platform (Linux, macOS, Windows)Modular Python linter wrapping PyFlakes, pycodestyle, and McCabe complexityPython 3.8.1+Checks async syntax via PyFlakes; extensible via flake8-async pluginParses annotations; checks type hints when combined with flake8-annotations pluginExtensive entry-point plugin ecosystem, pre-commit hooks, and IDE extensionsModular, lightweight PEP 8 compliance and linting with custom plugins
basedpyrightMIT LicenseCross-platform (Linux, macOS, Windows via Node.js/pip)Pyright fork with stricter default type checking and built-in Pylance featuresRuns on Python 3.10+; analyzes Python 3.0+Type checks async functions, coroutines, and asynchronous typing rulesAdvanced typing features, strict inference, baseline reporting, and unreachable code checkingLanguage server supporting VS Code, Neovim, Sublime Text, and pre-commitStrict, comprehensive static type checking without proprietary Pylance restrictions
ropeLGPL-3.0-or-laterCross-platform (Linux, macOS, Windows)Python refactoring library for safe renamings, extractions, and code restructuringsPython 3.8+ (supports Python syntax up to 3.15)Refactors and transforms async functions, methods, and await expressionsUses type annotations and docstrings to inform refactoring and inferenceIntegrates into python-lsp-server (pylsp), Vim, Emacs, and custom scriptsProgrammatic refactoring, code reorganization, and LSP refactoring backends
prospectorGPL-2.0-onlyCross-platform (Linux, macOS, Windows)Aggregates and unifies outputs from multiple Python static analysis toolsPython 3.8+Analyzes async code via underlying engines including Pylint and PyFlakesProvides static type checking by integrating optional Mypy tool supportWraps Pylint, pycodestyle, McCabe, pyflakes, Bandit, Mypy, and framework adaptorsZero-configuration, all-in-one Python code quality analysis combining multiple linters
complexipyMIT LicenseCross-platform (Linux, macOS, Windows)Fast cognitive complexity analyzer for Python code written in RustPython 3.8 to 3.15Calculates cognitive complexity across async functions, loops, and async comprehensionsIgnores type checking; cleanly parses annotated syntax without metric impactGitHub Actions, pre-commit hook, CLI, and JSON/CSV output formatsEnforcing cognitive complexity thresholds to keep Python functions easily understandable

每个单元格都来自该工具的官网、文档或代码仓库;页面列在参考资料中。

如何衡量

Every tool in the Code Analysis section of the community list vinta/awesome-python on GitHub that has a public repository, ranked by GitHub stars from the GitHub API; archived repositories are left out. Refreshed every 6 hours. ast-grep is left out: it's a multi-language tool, so its stars aren't Python's.

参考资料

  1. vinta/awesome-python: Code Analysis, GitHub community list (list text CC BY 4.0; star counts from the GitHub API). Checked 2026-11-23 16:43 UTC.
  2. vinta/awesome-python (Code Analysis), GitHub community list, 17 tools with a public repository.
  3. astral-sh/ruff: licence, github.com, checked 2026-11-15.
  4. black: licence, github.com, checked 2026-11-15.
  5. black: platforms, black.readthedocs.io, checked 2026-11-15.
  6. black: what it does, black.readthedocs.io, checked 2026-11-15.
  7. black: async support, black.readthedocs.io, checked 2026-11-15.
  8. black: type hints, black.readthedocs.io, checked 2026-11-15.
  9. black: plugins and ecosystem, black.readthedocs.io, checked 2026-11-15.
  10. mypy: licence, github.com, checked 2026-11-15.
  11. mypy: platforms, mypy.readthedocs.io, checked 2026-11-15.
  12. mypy: what it does, mypy.readthedocs.io, checked 2026-11-15.
  13. mypy: python versions, mypy.readthedocs.io, checked 2026-11-15.
  14. mypy: async support, mypy.readthedocs.io, checked 2026-11-15.
  15. mypy: type hints, mypy.readthedocs.io, checked 2026-11-15.
  16. mypy: plugins and ecosystem, mypy.readthedocs.io, checked 2026-11-15.
  17. ty: licence, github.com, checked 2026-11-15.
  18. ty: python versions, github.com, checked 2026-11-15.
  19. pyright: licence, github.com, checked 2026-11-15.
  20. pyright: platforms, microsoft.github.io, checked 2026-11-15.
  21. pyright: what it does, microsoft.github.io, checked 2026-11-15.
  22. pyright: python versions, microsoft.github.io, checked 2026-11-15.
  23. pyright: async support, microsoft.github.io, checked 2026-11-15.
  24. pyright: type hints, microsoft.github.io, checked 2026-11-15.
  25. pre-commit: licence, github.com, checked 2026-11-15.
  26. pre-commit: platforms, pre-commit.com, checked 2026-11-15.
  27. pre-commit: what it does, pre-commit.com, checked 2026-11-15.
  28. pre-commit: python versions, github.com, checked 2026-11-15.
  29. pre-commit: type hints, pre-commit.com, checked 2026-11-15.
  30. bandit: licence, github.com, checked 2026-11-15.
  31. bandit: platforms, bandit.readthedocs.io, checked 2026-11-15.
  32. bandit: python versions, github.com, checked 2026-11-15.
  33. bandit: async support, bandit.readthedocs.io, checked 2026-11-15.
  34. pyrefly: licence, github.com, checked 2026-11-15.
  35. pyrefly: platforms, pyrefly.org, checked 2026-11-15.
  36. pyrefly: python versions, github.com, checked 2026-11-15.
  37. pyrefly: type hints, pyrefly.org, checked 2026-11-15.
  38. isort: licence, github.com, checked 2026-11-15.
  39. isort: platforms, pycqa.github.io, checked 2026-11-15.
  40. isort: python versions, github.com, checked 2026-11-15.
  41. isort: type hints, pycqa.github.io, checked 2026-11-15.
  42. pylint: licence, github.com, checked 2026-11-15.
  43. pylint: platforms, pylint.readthedocs.io, checked 2026-11-15.
  44. pylint: python versions, pylint.readthedocs.io, checked 2026-11-15.
  45. pylint: async support, pylint.readthedocs.io, checked 2026-11-15.
  46. pylint: plugins and ecosystem, pylint.readthedocs.io, checked 2026-11-15.
  47. vulture: licence, github.com, checked 2026-11-15.
  48. vulture: platforms, github.com, checked 2026-11-15.
  49. vulture: python versions, github.com, checked 2026-11-15.
  50. flake8: licence, github.com, checked 2026-11-15.
  51. flake8: platforms, flake8.pycqa.org, checked 2026-11-15.
  52. flake8: plugins and ecosystem, flake8.pycqa.org, checked 2026-11-15.
  53. basedpyright: licence, github.com, checked 2026-11-15.
  54. basedpyright: platforms, github.com, checked 2026-11-15.
  55. basedpyright: what it does, docs.basedpyright.com, checked 2026-11-15.
  56. basedpyright: python versions, github.com, checked 2026-11-15.
  57. rope: licence, github.com, checked 2026-11-15.
  58. rope: platforms, rope.readthedocs.io, checked 2026-11-15.
  59. rope: python versions, github.com, checked 2026-11-15.
  60. prospector: licence, github.com, checked 2026-11-15.
  61. prospector: platforms, prospector.readthedocs.io, checked 2026-11-15.
  62. prospector: async support, prospector.readthedocs.io, checked 2026-11-15.
  63. import-linter: licence, github.com, checked 2026-11-15.
  64. import-linter: platforms, import-linter.readthedocs.io, checked 2026-11-15.
  65. import-linter: python versions, github.com, checked 2026-11-15.
  66. import-linter: plugins and ecosystem, import-linter.readthedocs.io, checked 2026-11-15.
  67. complexipy: licence, github.com, checked 2026-11-15.
  68. complexipy: platforms, complexipy.com, checked 2026-11-15.
  69. complexipy: python versions, github.com, checked 2026-11-15.
  70. complexipy: plugins and ecosystem, github.com, checked 2026-11-15.