black VS mypy

Compare black vs mypy and see what are their differences.

Our great sponsors
  • InfluxDB - Access the most powerful time series database as a service
  • Sonar - Write Clean Python Code. Always.
  • SaaSHub - Software Alternatives and Reviews
black mypy
281 95
31,748 15,051
2.1% 2.4%
9.6 9.9
10 days ago 7 days ago
Python Python
MIT License MIT License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

black

Posts with mentions or reviews of black. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-03-16.

mypy

Posts with mentions or reviews of mypy. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-03-24.
  • CS176a and Research Advice
    2 projects | reddit.com/r/UCSantaBarbara | 24 Mar 2023
    I'll try to address both of your replies, sorry for the wait. You should be comfortable with The Python Tutorial -- everything through Chapter 9 is really useful. Python is a good language to know for rapidly getting your ideas into the computer, for programming interviews and festive things like Advent of Code. I really recommend getting comfortable with Python's type annotations and a type checker like mypy. It will save you a lot of headache.
  • How do you code in a non-statically typed, imperative language after learning F#?
    3 projects | reddit.com/r/fsharp | 17 Mar 2023
    Use of optional types has been appearing in third party libraries more and more. The mypy type checker finally hit version 1, which I've been using for years. Flake8 for linting and black + isort for formatting are useful tools.
  • Python-based compiler achieves orders-of-magnitude speedups
    9 projects | news.ycombinator.com | 15 Mar 2023
  • What is the status of Python 3.11?
    2 projects | reddit.com/r/archlinux | 10 Mar 2023
  • Pain when going back to other languages
    2 projects | reddit.com/r/rust | 5 Mar 2023
    there was an attempt to make mypy disallow boolean tests on non-boolean, but it was removed https://github.com/python/mypy/issues/3195 . https://mypy.readthedocs.io/en/stable/error_code_list2.html#check-that-expression-is-not-implicitly-true-in-boolean-context-truthy-bool . mypy can at best check that a boolean context is used on variables that can be none, or define __bool__ or __len__ https://github.com/python/mypy/pull/13686 . Not great but that's already something. I wish requests could deprecate the __bool__ feature with some mypy annotation - it probably cannot be done.
  • Why Type Hinting Sucks!
    7 projects | reddit.com/r/Python | 10 Feb 2023
    But MyPy on strict is complaining that slow_add is missing a type annotation, after reading this issue you realize that @overload is only useful for users of your function but the body of your function will not be tested using @overload. Fortunately in the discussion on that issue there is an alternative example of how to implement:
    7 projects | reddit.com/r/Python | 10 Feb 2023
    https://github.com/python/mypy same with typeshed https://github.com/python/typeshed
    7 projects | reddit.com/r/Python | 10 Feb 2023
  • It is becoming difficult for me to be productive in Python
    8 projects | reddit.com/r/programming | 6 Feb 2023
    It's pretty common for codebases to use CI and CD to automatically package, run tests, upload, and/or deploy projects. If you add mypy to your CI test pipeline, then no code will pass tests that violates type annotations, and therefore, you can not deploy code that violates the stated types.
  • 40x Faster! We rewrote our project with Rust!
    5 projects | reddit.com/r/rust | 30 Jan 2023
    I use pyright as my LSP in Neovim for Python code, so I just use mypy for static type checking within CI/CD and GitHub actions.

What are some alternatives?

When comparing black and mypy you can also consider the following projects:

autopep8 - A tool that automatically formats Python code to conform to the PEP 8 style guide.

pyright - Static Type Checker for Python

yapf - A formatter for Python files

prettier - Prettier is an opinionated code formatter.

Pylint - It's not just a linter that annoys you!

isort - A Python utility / library to sort imports.

pyre-check - Performant type-checking for python.

pycodestyle - Simple Python style checker in one Python file

autoflake - Removes unused imports and unused variables as reported by pyflakes

Flake8 - flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.

pytype - A static type analyzer for Python code