Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
Update __exit__ parameters in stubs#9696
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Avasam commented Feb 9, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
srittau commented Feb 9, 2023
I'm not sure that replacing proper |
Avasam commented Feb 9, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Should non-star |
srittau commented Feb 9, 2023
I'd say ideally all _E=TypeVar("_E", bound=BaseException) classX: @overloaddef__exit__(self, __type: None, __value: None, __exc: None) ->None: ... @overloaddef__exit__(self, __type: type[_E], __value: type[_E], __exc: TracebackType) ->None: ...But since that is unwieldy, we can use the best approximation in a current situation. So I'm actually fine to use |
This comment has been minimized.
This comment has been minimized.
Avasam commented Feb 9, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Ok, I think my last commit satisfies your comment. (now the PR only adds new
Given this isn't a "stopgap", "urgent" or "in the meantime" PR. It's just splitting off a would-be bigger PR about semantically using |
srittau commented Feb 9, 2023
Side note: Changing |
JelleZijlstra commented Feb 22, 2023
This PR has a lot of conflicts now. I'd be hesitant to use the overloaded signature @srittau suggests, though it is probably technically correct:
|
Avasam commented Feb 22, 2023
Expected, but not hard to fix :) About the signature, should I leave it a-is, (can be done in a different PR and/or discussed further). At least get someway there? Or full-on change all signatures? |
This comment has been minimized.
This comment has been minimized.
AlexWaygood commented Feb 24, 2023
My preference would be to generally type def__exit__(self, *args: Unused) ->None: ...And to generally type def__exit__(self, exc_typ: type[BaseException] |None, exc_val: BaseException|None, exc_tb: TracebackType|None(There will obviously be exceptions to these rules where doing something else makes sense.) I agree with @srittau that using I also agree with @srittau that a truly precise signature for |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Avasam commented Feb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I know you said there could be exceptions. But that sounds like something Flake8-PYI could check for and/or add in its existing |
…/typeshed into __exit__-parameters-stubs
AlexWaygood commented Feb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Y036 actually used to be stricter, but Jelle persuaded me to relax it slightly in PyCQA/flake8-pyi#209 after we came across a situation in #7625 (comment) where there was a good case for doing something different. Maybe the exceptions that break the rule are rare enough that we could consider reverting that change... idk, I don't really have a strong opinion on exactly how strict flake8-pyi should be on this |
| def__enter__(self) ->Self: ... | ||
| def__exit__(self, exc_type: object, exc_value: object, traceback: object) ->None: ... | ||
| def__exit__( | ||
| self, exc_type: type[BaseException] |None, exc_value: BaseException|None, traceback: TracebackType|None |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it's still correct.
| def__enter__(self) ->Self: ... | ||
| def__exit__(self, exc_type: object, exc_value: object, traceback: object) ->None: ... | ||
| def__exit__( | ||
| self, exc_type: type[BaseException] |None, exc_value: BaseException|None, traceback: TracebackType|None |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it's still correct.
| asyncdef__aenter__(self) ->Self: ... | ||
| asyncdef__aexit__(self, exc_type: object, exc: object, tb: object) ->None: ... | ||
| asyncdef__aexit__( | ||
| self, exc_type: type[BaseException] |None, exc: BaseException|None, tb: TracebackType|None |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it's still correct.
| def__enter__(self) ->Self: ... | ||
| def__exit__(self, exc_type: object, value: object, traceback: object) ->None: ... | ||
| def__exit__( | ||
| self, exc_type: type[BaseException] |None, value: BaseException|None, traceback: TracebackType|None |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it's still correct.
| defxid(self, format_id, gtrid, bqual) ->Xid: ... | ||
| def__enter__(self) ->Self: ... | ||
| def__exit__(self, __type: object, __name: object, __tb: object) ->None: ... | ||
| def__exit__(self, __type: type[BaseException] |None, __name: BaseException|None, __tb: TracebackType|None) ->None: ... |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it's still correct.
| def__enter__(self) ->Protocol: ... | ||
| def__exit__(self, __exc_type: object, __exc_val: object, __exc_tb: object) ->None: ... | ||
| def__exit__( | ||
| self, __exc_type: type[BaseException] |None, __exc_val: BaseException|None, __exc_tb: TracebackType|None |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it's still correct.
| asyncdef__aenter__(self) ->Self: ... | ||
| asyncdef__aexit__(self, exc_type: object, exc_value: object, traceback: object) ->None: ... | ||
| asyncdef__aexit__( | ||
| self, exc_type: type[BaseException] |None, exc_value: BaseException|None, traceback: TracebackType|None |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it still makes sense.
| def__enter__(self) ->Self: ... | ||
| def__exit__(self, exc_type: object, exc_value: object, traceback: object) ->None: ... | ||
| def__exit__( | ||
| self, exc_type: type[BaseException] |None, exc_value: BaseException|None, traceback: TracebackType|None |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it's still correct.
| asyncdef__aenter__(self) ->Pipeline[_StrType]: ... | ||
| asyncdef__aexit__(self, exc_type: object, exc_value: object, traceback: object) ->None: ... | ||
| asyncdef__aexit__( | ||
| self, exc_type: type[BaseException] |None, exc_value: BaseException|None, traceback: TracebackType|None |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it's still correct.
| asyncdef__aenter__(self) ->Self: ... | ||
| asyncdef__aexit__(self, exc_type: object, exc_value: object, traceback: object) ->None: ... | ||
| asyncdef__aexit__( | ||
| self, exc_type: type[BaseException] |None, exc_value: BaseException|None, traceback: TracebackType|None |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it's still correct.
| def__enter__(self) ->Self: ... | ||
| def__exit__(self, exc_type: object, exc_value: object, traceback: object) ->None: ... | ||
| def__exit__( | ||
| self, exc_type: type[BaseException] |None, exc_value: BaseException|None, traceback: TracebackType|None |
AvasamFeb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
This used to be typed with objects. Please validate it's still correct.
Avasam commented Feb 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Me neither, just throwing suggestions :) Just in case, I flagged all the 3 parameters definitions that used to all be objects. |
This comment has been minimized.
This comment has been minimized.
AlexWaygood left a comment
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.
All the places you flagged look fine -- just one suggestion
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood left a comment
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.
Thanks!
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Follow-up to #9519 for third-party stubs now that a new version of mypy has been released
Ref #9297
I could not validate
psycopg2,hdbcliand_cffi_backendso I left those as-is