tushar.pyc
tush.ar
tushar.pyc
@tush.ar
Metaprogramming • Python / Zig / DevTools guy
The video for my PyCon JP 2024 talk "Crimes with the Python syntax" is out now!

youtu.be/fxiE6Tb5ofk
youtu.be
January 5, 2025 at 9:49 PM
Reposted by tushar.pyc
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
January 1, 2025 at 5:36 AM
Reposted by tushar.pyc
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.
December 26, 2024 at 1:49 PM
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)
December 22, 2024 at 10:31 AM
Something special is cooking...
December 20, 2024 at 5:47 AM
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
December 14, 2024 at 2:27 PM
Reposted by tushar.pyc
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!
December 8, 2024 at 11:31 AM
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
December 5, 2024 at 2:26 PM
TIL about the pytest.mock.usefixtures decorator

I continue to believe pytest has a feature for every conceivable use case.
When I need to pass a fixture to a pytest function that isn't directly referenced in the function body, my IDE dims the parameter, and it drives me nuts.

It turns out there's a way to pass implicit fixtures using the `pytest.mark.usefixtures` decorator. TIL:

rednafi.com/python/injec...
Injecting Pytest fixtures without cluttering test signatures
Sometimes, when writing tests in Pytest, I find myself using fixtures that the test function/method doesn’t directly reference. Instead, Pytest runs the fixture, and the test function implicitly lever...
rednafi.com
December 2, 2024 at 4:17 PM
Reposted by tushar.pyc
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
November 1, 2024 at 12:02 AM
Reposted by tushar.pyc
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...
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
github.com
November 30, 2024 at 8:06 AM
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...
GitHub - lebrice/SimpleParsing: Simple, Elegant, Typed Argument Parsing with argparse
Simple, Elegant, Typed Argument Parsing with argparse - lebrice/SimpleParsing
github.com
November 29, 2024 at 7:33 PM
Reposted by tushar.pyc
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 […]
Original post on mastodon.social
mastodon.social
November 28, 2024 at 4:45 AM
Reposted by tushar.pyc
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...
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...
snarky.ca
November 27, 2024 at 12:29 AM
Reposted by tushar.pyc
and now we put a bow on it: @python.org
November 26, 2024 at 2:28 PM
Reposted by tushar.pyc
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.
November 23, 2024 at 4:46 PM
Reposted by tushar.pyc
Unsure if you've seen this: jellezijlstra.github.io/why-cant-we#...
Why can’t we …?
jellezijlstra.github.io
November 21, 2024 at 7:45 PM
Reposted by tushar.pyc
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...
Ruff v0.8.0
The next stable version of Ruff is out now.
astral.sh
November 22, 2024 at 12:03 PM
Reposted by tushar.pyc
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...
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...
hynek.me
November 22, 2024 at 3:16 PM
Reposted by tushar.pyc
November 20, 2024 at 8:47 PM
Reposted by tushar.pyc
Did you know you can save 30% on PyCharm now and help support the #Python Software Foundation at the same time?

discuss.python.org/t/help-power...
Help power Python and join in the PSF year-end fundraiser & membership drive!
Hiya, folks 👋 Posting today to share that the PSF has launched our end-of-year fundraiser and we’d love for you to join in! There are three main ways to participate: Save on PyCharm! JetBrains is ...
discuss.python.org
November 20, 2024 at 4:43 PM
Reposted by tushar.pyc
This is clever. Because uv supports explicit indexes you can in fact switch pytorch versions based on environment markers. docs.astral.sh/uv/guides/in...
November 19, 2024 at 8:22 PM
What??(??)

source: justine.lol/lex
November 3, 2024 at 6:52 AM
TIL about the MANIFEST.in file for setuptools. Looks like this is the canonical way for adding files or folders outside your package into your source distribution.

(For non-python files within your package, package-data is enough)

setuptools.pypa.io/en/latest/us...
https://setuptools.pypa.io/en/latest/user…
November 2, 2024 at 2:40 PM