Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Pull Request Overview
This pull request removes Python 3.9 support from the Streamlit library and updates the codebase to utilize Python 3.10+ features. The changes modernize the type annotation syntax by replacing Union types with the newer | union operator and update typing_extensions imports to use the standard typing module where applicable.
Key changes include:
- Update minimum Python version requirement from 3.9 to 3.10
- Replace
Union[X, Y]type annotations withX | Ysyntax - Move
TypeAliasand other typing constructs fromtyping_extensionstotyping - Update
Callableimports to usecollections.abc.Callableinstead oftyping.Callable
Reviewed Changes
Copilot reviewed 131 out of 131 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/run_in_subdirectory.py | Uses native Path.is_relative_to() method instead of backported implementation |
| scripts/audit_frontend_licenses.py | Moves TypeAlias import from typing_extensions to typing |
| mypy.ini | Updates target Python version from 3.9 to 3.10 |
| lib/setup.py | Removes Python 3.9 from supported versions and updates minimum requirement |
| Multiple typing test files | Replaces Union types with ` |
| Multiple runtime/element files | Updates import statements for Callable and modernizes type annotations |
| Configuration files | Updates Python version references and build matrix |
| import json | ||
| import time | ||
| import uuid | ||
| from collections.abc import Callable |
There was a problem hiding this comment.
I'm wondering if we should make all of these import styles consistent. It seems like we are sometimes importing Callable top level, and sometimes using a TYPE_CHECKING block plus from __future__ import annotations. I think the latter is the preferred version for our codebase?
There was a problem hiding this comment.
Ruff enforces correct usage when it comes to TYPE_CHECKING and from __future__ import annotations. I'm not sure why Callable cannot be put into the TYPE_CHECKING block in this case, but ruff complains if we do this:
Could be a bug in ruff or caused by the advanced usage in the type, but I guess it might not be worth it to go a lot deeper on this.
There was a problem hiding this comment.
OK, sounds good. Based on my research, it seems like the combo of TYPE_CHECKING and from __future__ import annotations should be fine for all usages, but I agree it's not critical to update these.
| @@ -461,8 +460,7 @@ def __getattr__(self, key: str) -> Any: | |||
| return value | |||
| return AttrDict(value) | |||
| # We add FileNotFoundError since __getattr__ is expected to only raise | |||
There was a problem hiding this comment.
Do we still need FileNotFoundError since it seems like it was needed specifically for Python 3.9 according to the previous comment? Or was the issue always more general?
There was a problem hiding this comment.
_parse can throw an exception based on FileNotFoundError. I'm not sure if this is strictly Python 3.9 specific, but I think it's better to keep catching this if _parse throws and not risk a regression on this aspect.
📉 Python coverage change detectedThe Python unit test coverage has decreased by 0.0323%
💡 Consider adding more unit tests to maintain or improve coverage. Coverage by files
|
Describe your changes
Python 3.9 has reached end of life on the 1st October. This PR removes Python 3.9 from the supported Python versions and updates our codebase to make use of the latest features.
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.