Repository navigation
Conversation
This can be removed once it's fixed upstream in d1_python.
trey-stafford
left a comment
There was a problem hiding this comment.
The story mentions optionally dropping them since they're security-only, but I left that for a separate decision.
This could be a follow-on PR. It would be nice to update the min. Python to v3.13 (or even 3.14!). That would also require updating the mypy and ruff config to point at that min version as the target (e.g., too.mypy's python_version in pyproject.yaml). Probably not our biggest priority right now, but if it's easy enough to pull things forward I'd say go for it.
|
@trey-stafford could you take another look? I went ahead with your recommendation of updating the min. Python to v3.13 |
trey-stafford
left a comment
There was a problem hiding this comment.
I think the latest changes inadvertently added the filterwarning for root_path, which was removed. Otherwise I think this looks good!
| # FastAPI deprecates `FastAPI(root_path=...)` (seen in 0.162). The app still | ||
| # needs it to honor API_ROOT_PATH, so ignore the warning rather than change | ||
| # routing. Category is UserWarning because FastAPIDeprecationWarning subclasses it. | ||
| "ignore:The `root_path` parameter is deprecated:UserWarning", |
There was a problem hiding this comment.
We should be able to remove the root path warning.
|
|
||
| # Create a FastAPI dependency on the database session. | ||
| def _get_session() -> Generator[Session, None, None]: | ||
| def _get_session() -> Generator[Session]: |
There was a problem hiding this comment.
Nice - this is much clearer to me because I always have to refresh my memory on what the other two arguments are for, and why None is given.
| WorkflowTask: TypeAlias = Any | ||
| WorkflowScript: TypeAlias = Callable[..., WorkflowTask] | ||
| WorkflowTask = Any | ||
| WorkflowScript = Callable[..., WorkflowTask] |
There was a problem hiding this comment.
Did you try using the type keyword here? e.g., type WorkflowScript = Callable[..., WorkflowTask]? I think using that or TypeAlias is a little more explicit, although dropping clearly works. Was this something mypy or ruff caught?
There was a problem hiding this comment.
yes this was caught by ruff
Resolves #192
d1_commonthat breaks test collection on 3.14+3.11 and 3.12 are still supported and tested. The story mentions optionally dropping them since they're security-only, but I left that for a separate decision.
The d1_common issue
On 3.14+, every unit test failed at collection with:
This comes from a non-raw regex string in
d1_common/xml.py(dataone.libclient). Python emits it as aSyntaxWarning, but ourfilterwarnings = ["error"]setting escalates it to an error. 3.14 also reworded the warning message, which is why the filter uses a leading.*.The real fix is a one-character change upstream in d1_python (
b"..."→rb"..."). Worth doing eventually, since a future Python will turn this into an actual error and no filter will help then.Testing
Ran
typecheckandtest_unitlocally on each version: