Conversation
mjansche
commented
Nov 4, 2025
- Add py.typed.
- Revert to Union[] for compatibility with Python 3.9.
- Add type annotations to fix mypy warnings.
- Passes mypy --strict with Python 3.8 through Python 3.14.
|
This looks good to me! on main, this test (which doesn't actually exist, but should) actually does already pass: def test_bogus_conversion():
"""Tests !z errors"""
value = "Test"
assert value
with pytest.raises(SyntaxError):
t("hello {value!z}")This raises This PR DOES add a bit more runtime overhead to do this check, but I think it is worth the added complexity and perf hit. |
|
As a followup, I think I would prefer if we actually added the infrastructure to keep this passing the type checker. Eg we need to set this up with mypy, or actually I might suggest using ty. |
|
@sfermigier can you give this a look? If you give a thumbs up I can rebase on main so it is ready to merge |
|
ok. |
|
@mjansche our pyproject.toml only says we support python >=3.9. Is there a reason you need to support 3.8? Can you even use this package with 3.8? |
|
Also, see this CI run, which runs all the tests and checks on python 3.9. You say |
|
Ah, it may be because of the --strict flag. We don't use that flag in that linked PR. Once that PR is merged, then I will try adding the --strict flag, getting that to pass on just 3.9-3.14, and then I think we should revisit adding support for 3.8 |
I don't have a personal reason for using 3.8, but since I was testing my change with different versions, I threw in 3.8 for fun. No need to change the pyrpoject.toml from what it currently is, IMHO. |
* Add py.typed. * Revert to Union[] for compatibility with Python 3.9. * Add type annotations to fix mypy warnings. * Passes `mypy --strict src` with Python 3.8 through Python 3.14.