tushar.pyc's Avatar

tushar.pyc

@tush.ar

Metaprogramming • Python / Zig / DevTools guy

602
Followers
152
Following
26
Posts
28.10.2023
Joined
Posts Following

Latest posts by tushar.pyc @tush.ar

Preview
GitHub - beartype/ipython-beartype: IPython extension type-checking IPython environments with @beartype IPython extension type-checking IPython environments with @beartype - GitHub - beartype/ipython-beartype: IPython extension type-checking IPython environments with @beartype

I made a little thing:

You can now type check your Jupyter notebooks

github.com/beartype/ipy...

15.02.2025 08:05 👍 2 🔁 0 💬 0 📌 0

The video for my PyCon JP 2024 talk "Crimes with the Python syntax" is out now!

youtu.be/fxiE6Tb5ofk

05.01.2025 21:49 👍 4 🔁 1 💬 0 📌 0

Happy new year! Let's hope for a great 2025.

And if improving your #Python skills is part of your plan for the new year, check out my starter pack of Python teachers, authors, and speakers.

go.bsky.app/M5WjB4s

01.01.2025 05:36 👍 9 🔁 3 💬 1 📌 0

w

29.12.2024 14:08 👍 0 🔁 0 💬 0 📌 0
Post image

BTW thanks to folks pointing this out to me, I did find a solution to avoid CSS duplication between light/dark when user overrides are involved. Basically light-dark(...) does respect color-scheme.

26.12.2024 13:49 👍 42 🔁 2 💬 1 📌 0

TIL about `copy.replace()` in Python 3.13

Trying to edit a NamedTuple or frozen dataclass in Python is much simpler now: there's a new `__replace__` method on them, and the right API to use it is:

>>> v
Vector(x=1, y=2)
>>> import copy
>>> copy.replace(v, x=3)
Vector(x=3, y=2)

22.12.2024 10:31 👍 6 🔁 3 💬 0 📌 0
Post image

Something special is cooking...

20.12.2024 05:47 👍 1 🔁 0 💬 0 📌 0

Two tricks from the builtin `configparser` Python module that everyone should know:

- If you're parsing a .ini file with comments, remember to set the `inline_comment_prefixes` param to ignore inline comments

- Use `config.getboolean()` to parse '1', 'true', 'yes' etc. to True

14.12.2024 14:27 👍 2 🔁 0 💬 0 📌 0

Python achievement unlocked - use `functools.cmp_to_key` for the first time:

docs.python.org/3/library/fu...

Converts a comparison function into a key function - useful for an Advent of Code problem this year!

08.12.2024 11:31 👍 3 🔁 1 💬 2 📌 0

TIL even if a python package is nested inside a monorepo on github, you can install it with pip:

pip install git+github.com/<user>/<monorepo>#subdirectory=my/nested/package

05.12.2024 14:26 👍 14 🔁 2 💬 0 📌 0

this is horrifying, and I doubt I could help, but do let us know when you have a solution!

02.12.2024 16:25 👍 1 🔁 0 💬 0 📌 0

TIL about the pytest.mock.usefixtures decorator

I continue to believe pytest has a feature for every conceivable use case.

02.12.2024 16:17 👍 2 🔁 0 💬 1 📌 0

why not just .split()

02.12.2024 16:15 👍 0 🔁 0 💬 0 📌 0

building a fully complaint python parser for fun

02.12.2024 16:15 👍 1 🔁 0 💬 0 📌 0

atproto aha moments:

- you can host your data
- it's just json
- it's typed but any app dev can invent those types
- records have URIs
- records are signed so cacheable without trust
- relay aggregates everyone’s events into a global stream
- backends subscribe to relay and update local DBs

01.11.2024 00:02 👍 947 🔁 145 💬 43 📌 34
Preview
Apply PEP 639 (#1377) · python-attrs/attrs@3a5a49e https://discuss.python.org/t/pep-639-round-3-improving-license-clarity-with-better-package-metadata/53020/128

In case you wondered how to apply PEP 639 (better PyPI license metadata) in the most common case, here's an example: github.com/python-attrs...

And here's how it looks like on PyPI (see Meta section): test.pypi.org/project/attr...

30.11.2024 08:06 👍 7 🔁 1 💬 1 📌 0
Preview
GitHub - lebrice/SimpleParsing: Simple, Elegant, Typed Argument Parsing with argparse Simple, Elegant, Typed Argument Parsing with argparse - lebrice/SimpleParsing

Just found out about `SimpleParsing`, it's an extension of `argparse` but with type annotations and dataclass support, I like its API.

github.com/lebrice/Simp...

29.11.2024 19:33 👍 4 🔁 0 💬 0 📌 0
Original post on mastodon.social

Saw this release https://github.com/Yubico/python-fido2/releases/tag/1.2.0 and was excited to see stuff about WindowsClient extensions and "Extension APIs have been redesigned", thinking that maybe https://github.com/Yubico/python-fido2/issues/185 was finally addressed, but instead I see […]

28.11.2024 04:43 👍 1 🔁 1 💬 1 📌 0
Preview
What the PSF Conduct WG does In the past week I had two people separately tell me what they thought the PSF Conduct WG did and both were wrong (and incidentally in the same way). As such, I wanted to clarify what exactly the WG d...

I wrote a blog post explaining what the #PSF Conduct WG does since I have heard some people get it wrong.

snarky.ca/what-the-psf...

27.11.2024 00:29 👍 29 🔁 16 💬 1 📌 0

i still prefer the first one. and i believe abspath is unnecessary starting from python 3.10 or something?

removing abspath also means you never touch the filesystem for this line of code so it'll be significantly faster too.

27.11.2024 05:44 👍 0 🔁 0 💬 0 📌 0
Preview
PEP 718 – Subscriptable functions | peps.python.org This PEP proposes making function objects subscriptable for typing purposes. Doing so gives developers explicit control over the types produced by the type checker where bi-directional inference (whic...

this reminds me of pep 718: peps.python.org/pep-0718

While library maintainers would love this feature, I wonder what impact it will have on beginners when they accidentally do response.json["data"] instead of response.json()["data"], and instead of Python erroring, it gives a weird return value.

26.11.2024 19:04 👍 2 🔁 0 💬 0 📌 0

This perfectly shows how every language feature has a significant cost. In this case, Python choosing every runtime value (including function objects) to have a truth value (being True for most stuff) means errors like this can slip by.

I wonder what Python would look like without "truthiness".

26.11.2024 18:29 👍 1 🔁 0 💬 1 📌 0

and now we put a bow on it: @python.org

26.11.2024 14:28 👍 8 🔁 5 💬 1 📌 0

okay i need to try that next time!

24.11.2024 16:31 👍 1 🔁 0 💬 0 📌 0

they serve bentos on the shinkansen??

24.11.2024 13:04 👍 1 🔁 0 💬 1 📌 0

Hey! I’m Anthony.
I work on #Python stuff at Microsoft.
I wrote a book once about the Python compiler, blog sometimes and appear at the odd tech conference.

23.11.2024 16:46 👍 42 🔁 4 💬 7 📌 0
Why can’t we …?

Unsure if you've seen this: jellezijlstra.github.io/why-cant-we#...

21.11.2024 19:45 👍 2 🔁 1 💬 1 📌 0
Preview
Ruff v0.8.0 The next stable version of Ruff is out now.

OMG I DON'T HAVE TO SORT __all__ AND __slots__ BY HAND ANYMORE!

I was annoyed literally every time I had to do it.

astral.sh/blog/ruff-v0...

22.11.2024 12:03 👍 74 🔁 9 💬 7 📌 1
Preview
Semantic Versioning Will Not Save You The widely used Python package cryptography changed their build system to use Rust for low-level code, which caused an emotional GitHub thread. Enthusiasts of 32-bit hardware from the 1990s aside, a v...

I re-read @hynek.me 's article on SemVer and this cracked me up

"...your users will know what’s going on. But they won’t be happy about it and it may bring some negative vibes to your tropical vacation, financed by the millions you’ve made from maintaining a FOSS project."

hynek.me/articles/sem...

22.11.2024 15:16 👍 20 🔁 1 💬 2 📌 1

thredo but written with asyncio as its backend is a really interesting project right now. unfortunately i haven't been able to find the time for it in the past few months :^)

22.11.2024 06:38 👍 1 🔁 0 💬 0 📌 0