-
Notifications
You must be signed in to change notification settings - Fork 43
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
Reduce number of Optional
return values
#217
Conversation
extra side_effect extra side_effect
extra type ignore
|
||
|
||
class CallList(list, mock.NonCallableMock): | ||
def __init__(self, *args, name="respx", **kwargs): | ||
super().__init__(*args, **kwargs) | ||
def __init__(self, *args: Sequence[Call], name: Any = "respx") -> None: |
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.
Perhaps name: str | None
to mimic NonCallableMock
?
def __init__(self, *args: Sequence[Call], name: Any = "respx") -> None: | |
def __init__(self, *args: Sequence[Call], name: str | None = "respx") -> None: |
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.
Totally agree, but it's not possible due to this "unfortunate" solution ... https://github.com/lundberg/respx/blob/master/respx/models.py#L115
I use the route instance as mock name
to allow it to be dynamic/lazy.
To give some context, the name is only visible on assertion errors, e.g. when accessing NonCallableMock .assert_called_once
etc, and passing the route as name is to render an up-to-date repr/str when that happens.
Not a pretty solution, neither an important one 😉.
9aa3f76
to
482b6d7
Compare
Codecov Report
@@ Coverage Diff @@
## master #217 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 20 20
Lines 2740 2796 +56
Branches 337 350 +13
=========================================
+ Hits 2740 2796 +56
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
482b6d7
to
06ff405
Compare
3.11
to nox test ssessionmypy
on both tests and respxCall.has_response
helperCall.response
to raise instead of being optionalCallList.last
to raise instead of being optionalM()
, andRoute.pattern
, to not be optional by introducing aNoop
pattern