Skip to content

Add typing for _core/_multierror.py#2742

Merged
jakkdl merged 16 commits intopython-trio:masterfrom
CoolCat467:typing-multierror
Aug 14, 2023
Merged

Add typing for _core/_multierror.py#2742
jakkdl merged 16 commits intopython-trio:masterfrom
CoolCat467:typing-multierror

Conversation

@CoolCat467
Copy link
Member

@CoolCat467 CoolCat467 commented Aug 6, 2023

Add typing for _core/_multierror.py

I would love feedback and any comments on how this could be improved to be more accurate.

@CoolCat467 CoolCat467 added the typing Adding static types to trio's interface label Aug 6, 2023
@codecov
Copy link

codecov bot commented Aug 6, 2023

Codecov Report

Merging #2742 (7a2ec85) into master (7090051) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2742   +/-   ##
=======================================
  Coverage   98.92%   98.92%           
=======================================
  Files         113      113           
  Lines       16708    16713    +5     
  Branches     3027     3026    -1     
=======================================
+ Hits        16528    16533    +5     
  Misses        124      124           
  Partials       56       56           
Files Changed Coverage Δ
trio/_core/_multierror.py 100.00% <100.00%> (ø)

@jakkdl
Copy link
Member

jakkdl commented Aug 6, 2023

Just as a general note, I think typing deprecated features are at the very bottom of the priority list - unless they're still in extensive use.

def __new__(cls, exceptions, *, _collapse=True):
def __new__(
cls, exceptions: Iterable[BaseException], *, _collapse: bool = True
) -> MultiError | Self:
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably have an @overload using Literal[False] - if collapse=False, it will return MultiError. Otherwise, it may return any exception.

Copy link
Member Author

Choose a reason for hiding this comment

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

Kind of did in b21b293 but not exactly

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding overloads for this ends up failing with type issues from conflicts between overloads. If anyone has any ideas, please share.

@CoolCat467 CoolCat467 marked this pull request as ready for review August 9, 2023 01:10
@CoolCat467 CoolCat467 changed the title WIP: Add typing for _core/_multierror.py Add typing for _core/_multierror.py Aug 9, 2023
Copy link
Contributor

@TeamSpen210 TeamSpen210 left a comment

Choose a reason for hiding this comment

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

Noticed a few things, including an assert which I believe isn't correct.

@CoolCat467 CoolCat467 requested a review from TeamSpen210 August 9, 2023 03:36
Copy link
Contributor

@A5rocks A5rocks left a comment

Choose a reason for hiding this comment

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

I don't really have much to say, this seems fine (pending others' approval).

def __reduce__(self):
def __reduce__(
self,
) -> tuple[object, tuple[type[Self], list[BaseException]], dict[str, bool],]:
Copy link
Contributor

Choose a reason for hiding this comment

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

why the trailing comma?

Copy link
Member Author

Choose a reason for hiding this comment

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

I used black formatting, not sure, I can try removing it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, still there after removing and re-running black format. Maybe black has a bug?

@jakkdl jakkdl enabled auto-merge (squash) August 14, 2023 12:00
@jakkdl jakkdl merged commit d6d650f into python-trio:master Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typing Adding static types to trio's interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants