Repository navigation
[pull] master from testing-cabal:master - #81
Merged
Merged
Conversation
This matches what the docstring says and is okay at runtime given we immediately wrap the passed attributes in a frozenset. Signed-off-by: Stephen Finucane <stephen@that.guru>
Add a new OptExcInfo, modelling what's in typeshed [1], and use this in places where we expect to have potentially empty exc_info responses. This allows us to remove a number of `type: ignore` statements. [1] https://github.com/python/typeshed/blob/b7ac9ee66/stdlib/_typeshed/__init__.pyi#L318 Signed-off-by: Stephen Finucane <stephen@that.guru>
The 3rd argument in a `sys.exc_info` tuple will never be `None` unless all arguments are `None`. Despite this, many of our types indicated otherwise. The root cause of this assumption appears to be the `_details_to_exc_info` helper, which handles test results that only understand the stdlib API (i.e. no `details` argument). We rework that helper to "re-raise" the `_StringException` we are capturing, allowing us to return a small stub traceback rather than `None`. This should have near-zero effect on end-users, beyond allowing them to walk the exception using e.g. `traceback.format_tb` if they so wished (not that it would be all that useful, given the shallowness of the traceback). Note that this means most of the modified functions here can now use the `ExcInfo` type alias. However, this is left to a future change to avoid overly-complicating this one. Signed-off-by: Stephen Finucane <stephen@that.guru>
To hold commonly used type aliases. We add ExcInfo and OptExcInfo, rolling out use of these to more parts of the codebase. Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Stephen Finucane <stephen@that.guru>
When called via a context manager, it's possible to provide a custom message to be checked against the string of the raised exception. Update the types to reflect this. Signed-off-by: Stephen Finucane <stephen@that.guru>
The value_re parameter in both MatchesException and ExpectedException was typed as `str | Matcher[BaseException] | None`, but this was too narrow. The use of a Matcher here involves a preprocessor like str(), which accepts any object. This causes AfterPreprocessing(str, ...) to be inferred as Matcher[object] rather than Matcher[BaseException]. Widen the type to reflect what is actually accepted at runtime. Signed-off-by: Stephen Finucane <stephen@that.guru>
mypy cannot infer the type of an empty dict. We need to explicitly type it. Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Stephen Finucane <stephen@that.guru>
Another round of typing fixes
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )