Skip to content

Use TYPE_CHECKING flag to avoid importing from typing_extensions at run time#877

Merged
achimnol merged 4 commits intoaio-libs:mainfrom
edgarrmondragon:fix-typing-extensions-import
Jul 18, 2024
Merged

Use TYPE_CHECKING flag to avoid importing from typing_extensions at run time#877
achimnol merged 4 commits intoaio-libs:mainfrom
edgarrmondragon:fix-typing-extensions-import

Conversation

@edgarrmondragon
Copy link
Copy Markdown
Contributor

@edgarrmondragon edgarrmondragon commented Jul 17, 2024

What do these changes do?

Use TYPE_CHECKING flag to avoid importing from typing_extensions at run time

Are there changes in behavior for the user?

typing_extensions would no longer be importable from this package, but users shouldn't be doing that anyway :)

Related issue number

#876

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.bug)
    • 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."

Closes #876

@edgarrmondragon edgarrmondragon marked this pull request as ready for review July 17, 2024 16:31
@edgarrmondragon
Copy link
Copy Markdown
Contributor Author

FWIW it seems the pre-commit hook for mypy is missing a bunch of actual typing problems, but it's probably beyond the scope of this PR to fix those:

$ mypy aiodocker tests
aiodocker/stream.py:83: error: Item "None" of "ResponseHandler | None" has no attribute "transport"  [union-attr]
aiodocker/stream.py:83: error: Item "None" of "Transport | Any | None" has no attribute "get_extra_info"  [union-attr]
aiodocker/stream.py:90: error: Argument 1 to "FlowControlDataQueue" has incompatible type "ResponseHandler | None"; expected "BaseProtocol"  [arg-type]
aiodocker/stream.py:92: error: Item "None" of "ResponseHandler | None" has no attribute "set_parser"  [union-attr]
aiodocker/stream.py:93: error: Item "None" of "ResponseHandler | None" has no attribute "force_close"  [union-attr]
aiodocker/stream.py:94: error: Incompatible types in assignment (expression has type "FlowControlDataQueue[Message]", variable has type "None")  [assignment]
aiodocker/stream.py:111: error: Item "None" of "Connection | None" has no attribute "transport"  [union-attr]
aiodocker/stream.py:112: error: Item "None" of "Transport | Any | None" has no attribute "write"  [union-attr]
aiodocker/stream.py:113: error: Item "None" of "Connection | None" has no attribute "protocol"  [union-attr]
aiodocker/stream.py:114: error: Item "None" of "ResponseHandler | Any | None" has no attribute "transport"  [union-attr]
aiodocker/stream.py:115: error: Item "None" of "ResponseHandler | Any | None" has no attribute "_drain_helper"  [union-attr]
aiodocker/stream.py:123: error: Item "None" of "Connection | None" has no attribute "transport"  [union-attr]
aiodocker/logs.py:44: error: Incompatible types in assignment (expression has type "ClientResponse", variable has type "None")  [assignment]
aiodocker/docker.py:134: error: Argument "ssl" to "TCPConnector" has incompatible type "SSLContext | None"; expected "bool | Fingerprint | SSLContext"  [arg-type]
Found 14 errors in 3 files (checked 39 source files)

Copy link
Copy Markdown
Member

@achimnol achimnol left a comment

Choose a reason for hiding this comment

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

LGTM!

@achimnol achimnol enabled auto-merge (squash) July 18, 2024 11:48
@achimnol achimnol merged commit e2af544 into aio-libs:main Jul 18, 2024
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.

Missing dependency makes current release unusable

2 participants