ben · @benjamineskola
80 followers · 625 posts · Server hachyderm.io

I am not enjoying the way can suddenly find new type errors in code that hasn't changed at all.

(but only in CI! so if i add a comment to ignore the ‘error’, local mypy — the same version — complains that the comment is unnecessary.)

#mypy #python

Last updated 1 year ago

mugnaini · @mugnaini
93 followers · 11 posts · Server hachyderm.io

Is there any *good* type-checker for python? But I really mean a good one... I had bad experiences with mypy being not smart enough and even pyre-check can't handle `Optional` types correctly (similar issue with mypy).

Should I just give up on trying to have a better experience with python and just accept the fact that it is an inherently bad language to type-check?

#python #mypy #pyre #typechecker #typehints

Last updated 1 year ago

Zachary Cutlip · @zcutlip
407 followers · 1130 posts · Server hachyderm.io

Yesterday mypy forced me to learn about covariance, contravariance (and by extension invariance) in the context of programming language typing which isn't exactly what I signed up for, but it's hard to complain about learning new things so ¯\_(ツ)_/¯

github.com/zcutlip/pyonepasswo




#python #mypy #computerscience #programming

Last updated 1 year ago

Michał Górny · @mgorny
184 followers · 830 posts · Server pol.social

No więc dzisiaj aktualizuję do 1.5.1, i widzę, że nie ma żadnych zmian w kodzie, tylko zmiana numeru wersji. Mały CDF (co do faki?).

Teraz ztrawhcse gada mi na IRC-u, że przecież zmiany są:

github.com/python/mypy/compare

ja na to: no tak, czyżby nadpisali tag? Więc wymuszam ponowne pobranie, ale suma kontrolna się zgadza. Coraz większe CDF. Pobieram przez przeglądarkę, dostaję ten sam plik.

Wtedy ściągam 1.5.0… i mamy facepalm miesiąca. Nadpisali 1.5.0 na wcześniejszą wersję kodu już po tym, jak zaktualizowaliśmy paczkę w Gentoo.

Innymi słowy, użytkownicy Gentoo właściwie używali 1.5.1 już od tygodnia. Nie musicie nam dziękować.

#python #mypy

Last updated 1 year ago

C. · @cazabon
166 followers · 4009 posts · Server mindly.social

@folkerschamel @ado

Asking for specific type checking finds is ... unproductive. You write 2 modules of code, run , and get a list of the 11 places you need to fix - before you've even written unit tests that may or may not have caught the same problem.

If I tried to keep track of them all, I wouldn't have time to write code.

[...]

#examples #mypy #typehints #typechecking #tests #lint

Last updated 1 year ago

gram · @orsinium
107 followers · 490 posts · Server fosstodon.org

@kellogh In , already reports not awaited functions that you don't assign anywhere. And if you do assign, you'll get a type error when you try to use it as a value instead of as a coroutine.

#python #mypy

Last updated 1 year ago

gram · @orsinium
105 followers · 448 posts · Server fosstodon.org

@EMR @astraluma I know a few tools!

github.com/typeddjango/awesome

The difference in these tools is where you want to put your type tests: next to regular tests, in yaml, or in a separate Python file(s). The first approach is bad if you don't want to exclude all your tests from type checker. The second one is fine but you lose autocomplete and linters. I'm the author of the third way:

github.com/orsinium-labs/mypy-

Also, basic tests are possible with just :

pythonetc.orsinium.dev/posts/a

#mypy #python

Last updated 1 year ago

partizan · @partizan
159 followers · 13263 posts · Server mstdn.social

@ambv so, what do you think about this problem?

It also behaves the same way in mypy. But here bug is not closed, and i'm hoping it can be fixed.

github.com/python/mypy/issues/

#pyright #mypy #pythontyping #Python

Last updated 1 year ago

пан Партизан · @partizan
156 followers · 13034 posts · Server mstdn.social

Is there a way to create type stub only for part of the library?

For example: I want to include types for a single object, but don't want to maintain full copy of the library.

github.com/carltongibson/djang

#mypy #pylance #pyright #pythontyping #Python

Last updated 1 year ago

Timothée Mazzucotelli :python: · @pawamoy
138 followers · 203 posts · Server fosstodon.org

Is it me or just got a whole lot faster? It feels like it runs as fast as now! 😄

#mypy #ruff

Last updated 1 year ago

Timothée Mazzucotelli :python: · @pawamoy
138 followers · 203 posts · Server fosstodon.org

I really enjoy updates: transparent, regression-free, and each time it seems understands more things about my code, so I can remove some type-ignore comments. Kudos to 's maintainers and contributors!

#mypy

Last updated 1 year ago

gram · @orsinium
45 followers · 149 posts · Server fosstodon.org

@python_discussions That's not true. You need to specify `__all__` in `__init__.py` (and other facades) so that , , and know that these packages are imported to be exported. Then flake8 and ruff won't report unused import and mypy will allow reexports from the module.

#mypy #flake8 #ruff #python

Last updated 1 year ago

gram · @orsinium
34 followers · 129 posts · Server fosstodon.org

@glowrocks That's great! I'm glad to hear it empowers you to achieve your goals.

If you need guidance on more classic and reliable tools, just ask. In , I recommend to have a look at and , if you haven't already. These are good for finding simple errors without running the code. And Deal and Hypothesis should help with generating tests.

#python #ruff #mypy

Last updated 1 year ago

gram · @orsinium
34 followers · 129 posts · Server fosstodon.org

@benc mypy will report it by default, unless the name you are trying to import is aliased in the proxy module using `as` or included in `__all__`:

mypy.readthedocs.io/en/stable/

Edit: reading the docs again, I see that reexport is allowed by default, you have to explicitly forbid it in the mypy config.

#python #mypy

Last updated 1 year ago

ethantyping · @ethantyping
131 followers · 123 posts · Server hachyderm.io

Just saw that there is now an official VSCode extension from Microsoft for using mypy.

marketplace.visualstudio.com/i

Very cool!

#python #mypy #vscode

Last updated 1 year ago

ljmc ~͛ :unverified: :python: · @ljmc
3 followers · 12 posts · Server fosstodon.org

Having recently tested I find my toolchain for does 98% of the code quality job, the rest being covered by code review. What do you think and what do you use ?

#sonarqube #black #isort #flake8 #mypy #python

Last updated 1 year ago

ottO · @ottobackwards
103 followers · 1114 posts · Server fosstodon.org

Anyone out there having to support more than one version of MyPy|TypeShed|mypy-extensions|python with the same codebase?

Even with having different .mypy.ini's sometimes the hints in the code are incompatable and you end up playing whack a mole.

For example, is it r: Redis or r: Redis[bytes] or Redis[str]?

#mypy #python

Last updated 1 year ago

~ashwinvis · @ashwinvis
466 followers · 308 posts · Server mastodon.acc.sunet.se

executing as a daemon with an sqlite cache makes it go really fast. Squashed a lot of type errors with that workflow.

mypy.readthedocs.io/en/stable/

mypy.readthedocs.io/en/stable/

dmypy run -- --sqlite-cache --use-fine-grained-cache <path>
dmypy check <path>

#typing #python #mypy #til

Last updated 1 year ago

__coatldev__ · @__coatldev__
1 followers · 9 posts · Server fosstodon.org
Daniel Obraczka · @dobraczka
9 followers · 10 posts · Server sigmoid.social

Is there a common way to typehint slice? Especially for cases, when you want specific things like label-based slicing (think Pandas `.loc` for a string index). Pandas does not have any typehints for keys afaik.

#pandas #Python #DataScience #mypy

Last updated 1 year ago