-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a Geolocation dependency. #167
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #167 +/- ##
==========================================
+ Coverage 98.25% 98.43% +0.17%
==========================================
Files 11 11
Lines 862 892 +30
==========================================
+ Hits 847 878 +31
+ Misses 15 14 -1
|
@attrs.define | ||
class MyPageObject(BasePage): | ||
product: Product | ||
geolocation: Annotated[Geolocation, "DE"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked it, but wonder if something like this would work:
class _Geolocation:
pass
def Geolocation(geolocation: str):
return Annotated[_Geolocation, geolocation]
@attrs.define
class MyPageObject(ProductPage):
geolocation: Geolocation("DE")
Where does it break?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error: Invalid type comment or annotation [valid-type]
from mypy, though the runtime code works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Let's not handle it here then. This mypy issue seems relevant: python/mypy#13643 (with a suggested workaround).
@@ -150,6 +154,10 @@ async def __call__( # noqa: C901 | |||
cls_stripped = strip_annotated(cls) | |||
assert isinstance(cls_stripped, type) | |||
kw = item_keywords.get(cls_stripped) | |||
if cls_stripped is Geolocation and is_typing_annotated(cls): | |||
item = AnnotatedResult(Geolocation(), cls.__metadata__) # type: ignore[attr-defined] | |||
results.append(item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need to update cache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it the purpose of the cache is to skip requesting things, and we don't request Geolocation, but also we don't want to remove it from to_provide like it would be done if it's found in the cache. On the other hand I don't know in which cases is the cache currently used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also is it possible to request a Product without a Geolocation, cache it and then get that instance when the provider code is called again with a Geolocation, thus getting a wrong one?
No description provided.