Skip to content
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

Use Sequence instead of List for nameservers, as List is invariant #961

Merged
merged 1 commit into from Jul 19, 2023
Merged

Use Sequence instead of List for nameservers, as List is invariant #961

merged 1 commit into from Jul 19, 2023

Conversation

av223119
Copy link
Contributor

without this, resolver.nameservers = string.split() produces mypy error, see
https://mypy.readthedocs.io/en/stable/common_issues.html#invariance-vs-covariance

@av223119
Copy link
Contributor Author

mypy error message:

error: Incompatible types in assignment (expression has type "list[str]", variable has type "list[Union[str, Nameserver]]")  [assignment]
note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
note: Consider using "Sequence" instead, which is covariant

code in question

my_resolver = dns.resolver.Resolver()
my_resolver.nameservers = os.environ["DNS"].split()

@rthalley rthalley merged commit 7c78b94 into rthalley:master Jul 19, 2023
7 checks passed
@rthalley
Copy link
Owner

Thanks!

rthalley pushed a commit that referenced this pull request Jul 19, 2023
#961)

without this, resolver.nameservers = string.split() produces mypy error, see
https://mypy.readthedocs.io/en/stable/common_issues.html#invariance-vs-covariance

(cherry picked from commit 7c78b94)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants