materialsproject / crystaltoolkit

Crystal Toolkit is a framework for building web apps for materials science and is currently powering the new Materials Project website.
https://docs.crystaltoolkit.org
Other
135 stars 57 forks source link

Switch to Python 3.10 for testing and dependency upgrades #374

Closed mkhorton closed 8 months ago

mkhorton commented 8 months ago

Unless there are any objections from the community, I'd like to switch to Python 3.10+ to simplify development and allow usage of Python 3.10+ typing features.

mkhorton commented 8 months ago

@janosh would it be possible to make the Percy dashboard public? I don't think I can review otherwise.

janosh commented 8 months ago

@mkhorton I had nothing to do with setting up Percy on this repo. I thought that was you.

Re typing, IIUC crystal_toolkit/settings.py is the only file in which we can't use the pipe operator for type unions unless using 3.10. All other features can be used in all files with from __future__ import annotations.

mkhorton commented 8 months ago

Ah, interesting. I did set it up a long time ago, it seems like they were acquired by another company since I last set it up, maybe that’s why my credentials weren’t working. I’ll try and regenerate the API key.

mkhorton commented 8 months ago

Why was it only the settings.py that can’t use the pipe operator?

janosh commented 8 months ago

Why was it only the settings.py that can’t use the pipe operator?

That's the only one that defines a pydantic model. I don't know the details but pydantic hooks into the forward ref evaluation of type hints in a way that somehow messes with the way this was back-ported to older python versions via from __future__ import annotations.

janosh commented 8 months ago

That said I have no issues with 3.10+. Modern Python is more fun. 😄

mkhorton commented 8 months ago

Makes sense. I was confused why the futures annotation wasn't working, I think I concluded that I had misunderstood something. I also had an issue with TypeAlias (which I think needs typing_extensions?). In either case, let's switch to 3.10 for CI, but I think if I change the settings.py we can keep 3.9 for the project requirements.

mkhorton commented 8 months ago

Ok Percy integration should now be active again and public. All new PRs should now have screenshots attached(!)