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

pkg_resources: Expose the type of imports and re-exports #4242

Closed
Closed
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import time
import re
import types
from typing import List, Protocol
from typing import TYPE_CHECKING, List, Protocol
import zipfile
import zipimport
import warnings
Expand Down Expand Up @@ -65,20 +65,35 @@
from os import open as os_open
from os.path import isdir, split

from pkg_resources.extern.jaraco.text import (
yield_lines,
drop_comment,
join_continuation,
)
if TYPE_CHECKING:
# Replicates the imports below in a way that can be understood by type-checkers
from jaraco.text import (
yield_lines,
drop_comment,
join_continuation,
)
import platformdirs
import packaging
import packaging.version
import packaging.specifiers
import packaging.requirements
import packaging.markers
import packaging.utils
Avasam marked this conversation as resolved.
Show resolved Hide resolved
else:
from pkg_resources.extern.jaraco.text import (
yield_lines,
drop_comment,
join_continuation,
)

from pkg_resources.extern import platformdirs
from pkg_resources.extern import packaging
from pkg_resources.extern import platformdirs
from pkg_resources.extern import packaging

__import__('pkg_resources.extern.packaging.version')
__import__('pkg_resources.extern.packaging.specifiers')
__import__('pkg_resources.extern.packaging.requirements')
__import__('pkg_resources.extern.packaging.markers')
__import__('pkg_resources.extern.packaging.utils')
__import__('pkg_resources.extern.packaging.version')
__import__('pkg_resources.extern.packaging.specifiers')
__import__('pkg_resources.extern.packaging.requirements')
__import__('pkg_resources.extern.packaging.markers')
__import__('pkg_resources.extern.packaging.utils')

# declare some globals that will be defined later to
# satisfy the linters.
Expand Down
Loading