News for hackers. Stuff that matters.
Re:Python's new t-strings by tubthumper8 on Monday April 21, 2025 @08:52AM (#43751442)
Do the python type checkers / linters / whatever have the ability to warn or error on calling certain functions? That would be nice to eventually enforce migration over to the newer functions that only take a t-string template
Re:Python's new t-strings by mb5 on Monday April 21, 2025 @09:09AM (#43751614)
Re:Python's new t-strings by mos_basik on Monday April 21, 2025 @02:21PM (#43754874)
Yeah. A while back I was poking through some unfamiliar code and noticed that my editor was rendering a use of `datetime.utcnow()` as struck through. When I hovered it with my mouse, I got a message that that function had been deprecated.

Turns out my editor (vscode) and typechecker (pyright) saw that `datetime.utcnow()` was marked as deprecated (I know one can use the `@deprecated` decorator from Python 3.13 or `__future__` to do this; I think it was done another way in this particular case) and therefore rendered it as struck through.

And it taught me A) that `utcnow()` is deprecated and B) how to mark bits of our internal codebase as deprecated and nudge our developers to use the new, better versions if possible.

Re:Python's new t-strings by tubthumper8 on Wednesday April 23, 2025 @08:21AM (#43771260)
Can you do it for functions defined by other people, or only for functions that you defined?

I'm thinking in the general case, but motivated by this example of a 3rd party function that accepts a SQL query as a string, and we'd like everywhere in our codebase to stop using that and instead use the 3rd party function that accepts the query as a t-string