Skip to content

Conversation

VojtechStep
Copy link
Collaborator

We used to support Python 3.8 because of Ubuntu 20.04, which doesn't have LTS anymore. The successor, Ubuntu 22.04, comes with Python 3.10.
By upgrading we get tooling improvements --- we can update pre-commit-hooks and autopep8, the latter of which was disabled IIRC because the version we could use was buggy --- and we can also use new Python features, such as pattern matching and type aliases.

There's no time pressure, so I'm keeping it as a draft for now, since one nested Python dependency has recently been broken for Python 3.10 in nixpkgs, but I submitted a PR (NixOS/nixpkgs#447787) to fix that, and temporarily replicated the fix here (with the disadvantage of it not being prebuilt, hence waiting for the PR to be merged).

Note that I updated pre-commit/prettier, but it's not maintained anymore, because pre-commit apparently broke something, and IIUC there's now no officially supported way of running prettier in pre-commit 🤷.

Fixes #939

@VojtechStep
Copy link
Collaborator Author

I hate Python tooling man, why does the double-quote-string-fixer change f-strings in the CI but not on my laptop. It's the exact same Python version and the exact same version of the hook...

@fredrik-bakke
Copy link
Collaborator

Yeah, it's fucked :( Maybe it has something to do with locale?

@VojtechStep
Copy link
Collaborator Author

Right now I suspect that the rules are still run with a different Python version than the declared 3.10. Since there's no concept of "target Python version" in the formatter, it just formats it for whatever version of Python is running it. But if that's the case then we need to disable it anyway, because e.g. your local Python would then format it differently than the CI

@VojtechStep
Copy link
Collaborator Author

Alright, turns out my pre-commit was bundling its own Python 3.13, so the behavior in the CI was the correct one. When I convinced pre-commit to use the provided 3.10, it behaved the same as the CI, so that's at least something.
On the other hand, it confirms that running the double-quotation hook with newer Python versions will have different behavior, so I'm disabling it again

Until it's fixed upstream
Still supports Python 3.9
Still supports Python 3.9
Though it's deprecated now, and apparently there is no supporter way
to run prettier from pre-commit.

It also now considers some arrow characters double-width, since
Unicode classifies them as emojis; though I don't think it's worth it
to fight prettier on it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autoformatting for Python files
2 participants