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

Import Protocol from typing_extensions #5111

Merged
merged 1 commit into from
Oct 24, 2020

Conversation

layday
Copy link
Contributor

@layday layday commented Oct 24, 2020

What do these changes do?

Conditional imports must reference sys.version_info directly
for type checkers to be able to narrow them. If a type checker
cannot tell whether PY_38 is true, it will combine the imports
from both clauses in a Union.
However, typing.Protocol and typing_extensions.Protocol are
incompatible with each other - they do not inherit from the same class.
This produces a type error which is reported to users of aiohttp
depending on their type checking configuration.

Are there changes in behavior for the user?

No.

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@layday layday requested a review from asvetlov as a code owner October 24, 2020 11:39
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 24, 2020
@codecov-io
Copy link

codecov-io commented Oct 24, 2020

Codecov Report

Merging #5111 into master will decrease coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5111      +/-   ##
==========================================
- Coverage   97.51%   97.46%   -0.06%     
==========================================
  Files          43       43              
  Lines        8824     8821       -3     
  Branches     1415     1414       -1     
==========================================
- Hits         8605     8597       -8     
- Misses        102      105       +3     
- Partials      117      119       +2     
Flag Coverage Δ
#unit 97.46% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiohttp/helpers.py 96.69% <100.00%> (-0.03%) ⬇️
aiohttp/pytest_plugin.py 95.62% <0.00%> (-1.88%) ⬇️
aiohttp/web_fileresponse.py 97.84% <0.00%> (-0.54%) ⬇️
aiohttp/web_protocol.py 91.97% <0.00%> (-0.29%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e633968...6d22a98. Read the comment docs.

Conditional imports must reference `sys.version_info` directly
for type checkers to be able to narrow them.  If a type checker
cannot tell whether `PY_38` is true, it will combine the imports
from both clauses in a `Union`.
However, `typing.Protocol` and `typing_extensions.Protocol` are
incompatible with each other - they do not inherit from the same class.
This produces a type error which is reported to users of aiohttp
depending on their type checking configuration.
Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@asvetlov asvetlov merged commit fb8037a into aio-libs:master Oct 24, 2020
@aio-libs-github-bot
Copy link
Contributor

💔 Backport was not successful

The PR was attempted backported to the following branches:

  • ❌ 3.7: Commit could not be cherrypicked due to conflicts

asvetlov pushed a commit that referenced this pull request Oct 24, 2020
Conditional imports must reference `sys.version_info` directly
for type checkers to be able to narrow them.  If a type checker
cannot tell whether `PY_38` is true, it will combine the imports
from both clauses in a `Union`.
However, `typing.Protocol` and `typing_extensions.Protocol` are
incompatible with each other - they do not inherit from the same class.
This produces a type error which is reported to users of aiohttp
depending on their type checking configuration..
(cherry picked from commit fb8037a)

Co-authored-by: layday <31134424+layday@users.noreply.github.com>
asvetlov added a commit that referenced this pull request Oct 24, 2020
Conditional imports must reference `sys.version_info` directly
for type checkers to be able to narrow them.  If a type checker
cannot tell whether `PY_38` is true, it will combine the imports
from both clauses in a `Union`.
However, `typing.Protocol` and `typing_extensions.Protocol` are
incompatible with each other - they do not inherit from the same class.
This produces a type error which is reported to users of aiohttp
depending on their type checking configuration..
(cherry picked from commit fb8037a)

Co-authored-by: layday <31134424+layday@users.noreply.github.com>

Co-authored-by: layday <31134424+layday@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants