#mypy

Anyone else think that the Union type annotation in Python is a code smell that something is too loosely defined?
#python #mypy

Kevin Brown-Silvakevin@brown-silva.social
2025-05-18

Other #PyConUS sprints this week:

* #RAPIDSai
* django-simple-deploy and py-bugger
* #PyFyre, #MyPy, and #MyPyC
* MemRay
* #Ruff or Ty from Astral
* #WheelNext
* ci-test / linting-arguments-python

Additionally there will be an "Introduction to Sprints" open space in Room 310 at 6:00 PM.

#PyConUS2025

2025-05-16

@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.

Matthew Martinmistersql
2025-05-07

- but mypy already compiles itself to c via so being faster isn't what I'd be expecting, it will be different and probably find different typing errors since for all the type checkers, it comes down to a matter of opinion. Do you think that will be a runtime error? That's in the future, who knows man.

Charles Tapley Hoytcthoyt@scholar.social
2025-04-18

anyone have some time to help me with a tricky #python #typing and #mypy problem?

it's fully self-contained in github.com/cthoyt/python-typin. 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

2025-04-10

Our of the box, #pyright is "better" than #mypy . Less configuration and more strict!

2025-04-07

ok, a whole day of programming #Python with #mypy and #ruff.

this is much better than without, and ruff is very fast, but mypy is slooooow.

Also, the type system just isn't all that good

Adam Johnson :django: :python:adamchainz@fosstodon.org
2025-03-26

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.

#Python #MyPy

adamj.eu/tech/2022/08/23/pytho

2025-03-25

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 : github.com/neubig/starter-repo

Libre à chaque personne de faire évoluer le porojet selon ses propres goûts et contraintes.

sumanthvepasumanthvepa
2025-03-18

introduced me to a couple of cool things in today. When you know that a function returns a specific type you can use assert to let know that. Or you can use the cast() or TypeGuard.

chatgpt.com/share/67d9f37a-543

2025-03-13

Аннотации типов в Python: коротко о главном

Привет, Хабр! Сегодня рассмотрим, как Python, оставаясь динамически типизированным, может приближаться к строгой типизации. Всё дело в аннотациях типов , которые позволяют явно указывать, какие данные ожидаются в переменных, аргументах функций и возвращаемых значениях. Аннотации сами по себе не заставляют Python проверять типы во время выполнения, но их можно использовать вместе с инструментами статического анализа. В первую очередь мы будем работать с mypy — популярным инструментом, который выявляет ошибки до запуска программы.

habr.com/ru/companies/otus/art

#python #аннотации_типов #строгая_типизация #mypy

New account, so new #introduction. Let's do it again!

I have a
#MastersDegree in #ComputerScience and #ComputerEngineering. I went to #NMU for undergrad and #MSU for my graduate degree. I currently work at #UChicago for the #TMWCenter, which focuses on helping young children acquire language (and therefore other learning skills) faster.

In my spare time, I develop
#OpenSourceSoftware such as
- a
#SphinxDoc extension that embed #Fediverse comments on your page
- a library to talk to
#ManifoldMarkets from native #Python
- a
#PredictionMarket manager using the above
- a
#transpiler from a subset of Python to #OpenStreetMaps's #OverpassQL
- bug fixes to many other projects, including
#mypy, #base58, #attrs, #CPython, & more

I spend a fair bit of my time these days on
#MathResearch, specifically into the #ThueMorse Sequence and its extensions.

I'm also a hobbyist editor on OpenStreetMap.

#Demisexual, #transfem, and happily engaged to my #enby sweetheart.

We have two cats:
#OpheTheLoaf and #MayalaranTheCat (yes, from #StormlightArchive) See here for more on them!

I speak English fluently, Spanish haltingly, and am trying to learn Chinese

#queer #Chicago

2025-02-03

The static type annotation system in Python (and associated typecheckers) really turns it into a business-ready language. I'm making some big refactors, and I don't know how I would pull them off without type verification.

So many situations where I change a function signature and discover it's being called ⬅️ ⬅️ ⬅️ ⬅️ ⬅️ ⬅️ ⬅️ ⬅️ alllllll the way over there and would just runtime-error without mypy letting me know the signatures no longer match.

Seriously, static type annotation alone has moved Python from "cute toy language" to "production-worthy" in my professional toolbox.

#Python #mypy

Charles Tapley Hoytcthoyt@scholar.social
2025-01-31

every time I run mypy and wait for it to finish, I wonder if 2025 will be the year of a red knot announcement/release from @charliermarsh and Astral

I already have a placeholder issue on my cookiecutter template repo: github.com/cthoyt/cookiecutter

#python #typing #typeannotations #mypy #ruff #uv

sumanthvepasumanthvepa
2025-01-25

@loganer Yes. Python is dynamically typed. I use a lot to compensate for the weak typing. And it's fairly decent.

But one loses something when one tries to use a programming style meant for a language with different design criteria.

Programming Python in a Lisp or Scheme like style can be very powerful. It's not something we do in C++ a lot, so it feels foreign.

Ironically, I think the parameterized package would actually benefit from being more dynamic in this case.

sumanthvepasumanthvepa
2025-01-25

And one that supported

Arie van Deursen 🇳🇱🇪🇺🟥avandeursen@mastodon.acm.org
2025-01-23

Survey on use of types in Python among around 1000 developers. 88% of respondents “Always” or “Often” use Types in their Python code.

Study conducted by Meta, JetBrains, and Microsoft, results on a Google dashboard.

engineering.fb.com/2024/12/09/

#python #mypy #pycharm #pyright

2024-12-30

I posted what's probably my last blog post of 2024: Mutually tail-call optimization in Python, passing mypy --strict type-checking to boot! emergent.unpythonic.net/017355

#python #mypy #recursion #tailRecursion

2024-12-18

Oh dang, my #introduction post is waaay out of date now. Let's do it again!

I have a #MastersDegree in #ComputerScience and #ComputerEngineering. I went to #NMU for undergrad and #MSU for my graduate degree. I currently work at #UChicago for the #TMWCenter, which focuses on helping young children acquire language (and therefore other learning skills) faster.

In my spare time, I develop #OpenSourceSoftware such as

I spend a fair bit of my time these days on #MathResearch, specifically into the #ThueMorse Sequence and its extensions.

I'm also a hobbyist editor on OpenStreetMap.

#Demisexual, #transfem, and happily engaged to my #enby sweetheart.

We have two cats: #OpheTheLoaf and #MayalaranTheCat (yes, from #StormlightArchive)

#queer #Chicago

Two cats are by a sliding glass window. The one towards the top of the frame (named Ophelia) is laying on a heat pad and staring at the second cat. The second cat (named Maya) is towards the bottom of the frame. She is sat on the entry rug with her body poked between the blinds on the window, so that she can look outside.There are two cats in frame, near a very small cat tower. On top of the tower, Ophelia is laying down. Below, in a meercat-like pose, is Maya. She is trying to get a better view of the other cat. They didn't know each other very well at this time.A gray cat, Maya, is laying on the couch. She is curled up such that her belly and paws are all exposed, though her tail is tucked near her feet. She looks peacefully asleepA gray/gray-orange cat is laying on a white blanket. Her name is Ophelia, and she has one eye half open, which is a brilliant green-orange. She is very relaxed. You get the faint impression of a person's legs underneath the blanket
2024-12-13

@cdavies I really really want to hate #python sometimes but can't. The darn thing is so useful. Nothing beats it for anything <1k loc! And no matter what you want to do, it is second or third best choice available.

But as a language for developing systems, it sucks! C-API is terrible (shoutout to #pybind11 and #maturin). Dynamic typing becomes a bane (#mypy helps). For last two days, I am tweaking a #fastapi, I miss rust type safety when refactoring.

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst