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.
What does this Pull Request accomplish?
_with_typed_session()
was incorrectly assuming that the runtime type matches the static type. Also, it was trying to infer the static type variableTSession
based on the runtime type expressiontype(session)
.Fixing this revealed a problem with the tests: patching
driver.Session
and replacing it with a mock causesisinstance
checks to fail. The 2nd argument toisinstance
must be a type, so it raises an error ifdriver.Session
is aMock
instance rather than a type. Patchingdriver.Session.__new__
instead ofdriver.Session
avoids this problem because it ensures thatdriver.Session
is still a type. (Patchingdriver.Session
to replace it with a subclass that overrides__new__
would also work.)Why should this Pull Request be merged?
These type checks are needed for
get_connection(s)
What testing has been done?
Ran updated unit tests.