Skip to content

Conversation

rhysrevans3
Copy link
Contributor

@rhysrevans3 rhysrevans3 commented Feb 12, 2024

Related Issue(s):

Description:

PR Checklist:

  • pre-commit hooks pass locally
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the CHANGELOG.

@thomas-maschler
Copy link
Contributor

@rhysrevans3 looks like we had the same idea
#625

)
fields[k] = (v.outer_type_, body)
for k, field_info in model.model_fields.items():
fields[k] = (field_info.annotation, field_info)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomas-maschler sorry I should have checked before putting in the pull request it looks like most of our changes are the same. I found the field_info.annotation would leave out the Optional type unless I switched from typing List and Dict to the inbuilt list and dict.


## [Unreleased]

* Removing support for Python 3.8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? pydantic 2 does support python 3.8 https://github.com/pydantic/pydantic/blob/main/pyproject.toml#L65

@@ -1,4 +1,4 @@
FROM python:3.8-slim as base
FROM python:3.9-slim as base
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree to remove python 3.8 but then we should use python 3.11 IMO

extensions: List[ApiExtension] = attr.ib(default=attr.Factory(list))
exceptions: Dict[Type[Exception], int] = attr.ib(
extensions: list[ApiExtension] = attr.ib(default=attr.Factory(list))
exceptions: dict[Type[Exception], int] = attr.ib(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI is using dict directly instead of typing.Dict is the reason to switch to python>=3.9, typing.Dict is just an alias of dict (https://github.com/python/cpython/blob/3.9/Lib/typing.py#L1743C15-L1743C19) so it's fine to use typing.Dict IMO

https://stackoverflow.com/questions/37087457/difference-between-defining-typing-dict-and-dict

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same goes for List

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vincentsarago I found that during the create_request_model in models.py. The field_info.annotation would leave out the Optional part of the type. The only solution I found was to switch from typing List and Dict to the generic list and dict. There maybe a better solution to this?

@lossyrob
Copy link
Member

Is there a reason to keep both this and #625 open? Based on a quick review, looks like #625 has less changes - and by the author of the stac-pydantic upgrade (thank you @thomas-maschler !). If we can close this and focus the review on #625 that will be easier on reviewers. @rhysrevans3 anything in here related to the pydantic upgrade that deem a must-have that #625 doesn't already contain? Otherwise consolidating on #625 and getting your review on it would be a good path to get this unblocked IMO. Thanks for this PR, unfortunate instance of duplication of work!

@rhysrevans3 rhysrevans3 deleted the stac_pydantic_3 branch February 21, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants