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/

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/
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
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.
https://engineering.fb.com/2024/12/09/developer-tools/typed-python-2024-survey-meta/
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)
Enjoyed a morning walk listening to Intervista Pythonista italian podcast
Marco Santoni & Cesare Placanica hosted Alan Franzoni who discussed type-checking in Python and its application at Aiven with mypy
Highly recommend
https://podcasters.spotify.com/pod/show/marco-santoni/episodes/Type-checking-statico-su-grandi-codebase--Ep-55-e2lufum
A guide on integrating #emacs + #python + #hatch using [mostly] builtin tooling and project local .dir-locals.el variables.
Specifically, this setup uses #Eglot + #pyright for live syntax checking, #pytest for code running, #MyPy for type-checking, and #IPython as the shell
Feedback would be welcome -- trying to get it robust + idiomatic.
TIL in my #python #mypy adventures, the proper way to set up a class that returns itself is to use the `Self` typing annotation and return values by calling `self.__class__` on the new value
```python
from typing import Self
class ImActuallyAString(str):
def one_longer(self) -> Self:
return self.__class__(self + "one")
```
ᕕ( ᐛ )ᕗ (please tell me if I'm wrong lol)
@nedbat I couldn't find a cached version (quite probably I didn't look hard enough).
In my case, the offending part was:
class Foo:
bar: Bar = None
Tried:
class Foo:
bar: Optional[Bar] = None
This makes #mypy happy in that spot, but then I would have needed to disambiguate the type (via asserts and the like) all the time, so I went for something simple yet not entirely satisfactory:
class Foo:
bar: Bar = None # type: ignore
And everything else expects bar to be Bar, not None.
@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.
MyPy 1.0.0 has been released
"Mypy is a static type checker for Python. This release includes new features, performance improvements and bug fixes."
Some of them
- the new version numbers will be of form x.y.z
- version 1.0 is up to 40% faster than 0.991
- it will now generate an error if you use a variable before it’s defined
- mypyc can now compile Python 3.10 match statements
https://mypy-lang.blogspot.com/2023/02/mypy-10-released.html