Add typing to _ConnectionParameters
and related functions
#1199
+60
−37
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.
This adds typing to an important
NamedTuple
in this module that will allow using types in a lot of other functions that have a reference to this object.The final type looks very similar to what was suggested in #577 but this is based on the paths that the code can actually take. As with other PRs the strategy is simple: start with the lowest function in the call chain to see if the code can tell you what types it should accept and propagate upwards until you reach the
NamedTuple
.The most controversial change is probably
_ConnectionParameters.ssl
. This is because of the code path where we setsslmode = SSLMode.disable
. It is a bit annoying but that code path means thatssl
never gets reassigned and therefore will be whatever_parse_connect_dsn_and_args
accepts. We should probably change that to beNone
but I don't want to introduce behaviour changes in these PRs.The two actual runtime changes are straightforward and any mistakes in the typing we can (of course) always rectify later.