Namespace vs Regular Packages in Python — And Why mypy Might Be Failing You
Namespace vs Regular Packages in Python — And Why mypy Might Be Failing You
@seungjin I write #python code every day, and type hints are a "syntactic sugar" and are not required at all from the interpreter point of view.
For large projects, it's useful to add hints to "follow" what you are doing, and type checkers like #pyright or #mypy can help to find some bugs, by example when calling a method with wrong parameters types.
It also help for the readability of the code.
anyone have some time to help me with a tricky #python #typing and #mypy problem?
it's fully self-contained in https://github.com/cthoyt/python-typing-dilemma. It contains some examples of things I tried, and why they didn't work
it hinges on using PEP-696 defaults in typing.TypeVar, introduced in Python 3.13
I’m busy re-applying this “gradual import” technique on a client project today. Will slowly get them up to a full django-stubs installation.
https://adamj.eu/tech/2022/08/23/python-type-hints-gradually-add-types-for-third-party-packages/
Hynek Schlawack recently described graduality as Python’s super power: the ability to prototype in the REPL, and gradually add linting, type checking, and other practices to refine your code into maintainable, production-ready software. You can also apply graduality within tools, activating checks one at a time and fixing the resulting errors as you go.
Nous avons tous nos bonnes pratiques lorsqu'il s'agit de créer un nouveau #projet #Python, avec l'utilisation de patterns et d'outils éprouvés : lint avec #ruff et #mypy, hooks avec #precommit, tests avec #pytest, intégration continue #githubactions : https://github.com/neubig/starter-repo
Libre à chaque personne de faire évoluer le porojet selon ses propres goûts et contraintes.