Skip to content
Merged
Changes from all 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
34 changes: 17 additions & 17 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _sget_dict(val):
return val.copy()


def _sset_dict(key, ob, state):
def _sset_dict(key, ob, state) -> None:
ob.clear()
ob.update(state)

Expand All @@ -181,7 +181,7 @@ def _sget_object(val):
return val.__getstate__()


def _sset_object(key, ob, state):
def _sset_object(key, ob, state) -> None:
ob.__setstate__(state)


Expand Down Expand Up @@ -1090,7 +1090,7 @@ def subscribe(
for dist in self:
callback(dist)

def _added_new(self, dist):
def _added_new(self, dist) -> None:
for callback in self.callbacks:
callback(dist)

Expand Down Expand Up @@ -1463,7 +1463,7 @@ def get_cache_path(self, archive_name: str, names: Iterable[StrPath] = ()) -> st
return target_path

@staticmethod
def _warn_unsafe_extraction_path(path):
def _warn_unsafe_extraction_path(path) -> None:
"""
If the default extraction path is overridden and set to an insecure
location, such as /tmp, it opens up an opportunity for an attacker to
Expand Down Expand Up @@ -1577,7 +1577,7 @@ def safe_version(version: str) -> str:
return re.sub('[^A-Za-z0-9.]+', '-', version)


def _forgiving_version(version):
def _forgiving_version(version) -> str:
"""Fallback when ``safe_version`` is not safe enough
>>> parse_version(_forgiving_version('0.23ubuntu1'))
<Version('0.23.dev0+sanitized.ubuntu1')>
Expand Down Expand Up @@ -1779,7 +1779,7 @@ def _fn(self, base: str | None, resource_name: str):
return base

@staticmethod
def _validate_resource_path(path):
def _validate_resource_path(path) -> None:
"""
Validate the resource paths according to the docs.
https://setuptools.pypa.io/en/latest/pkg_resources.html#basic-resource-access
Expand Down Expand Up @@ -1890,7 +1890,7 @@ def _setup_prefix(self):
egg = next(eggs, None)
egg and self._set_egg(egg)

def _set_egg(self, path: str):
def _set_egg(self, path: str) -> None:
self.egg_name = os.path.basename(path)
self.egg_info = os.path.join(path, 'EGG-INFO')
self.egg_root = path
Expand Down Expand Up @@ -1918,7 +1918,7 @@ def _get(self, path) -> bytes:
return stream.read()

@classmethod
def _register(cls):
def _register(cls) -> None:
loader_names = (
'SourceFileLoader',
'SourcelessFileLoader',
Expand Down Expand Up @@ -2208,7 +2208,7 @@ def get_metadata(self, name: str) -> str:
self._warn_on_replacement(metadata)
return metadata

def _warn_on_replacement(self, metadata):
def _warn_on_replacement(self, metadata) -> None:
replacement_char = '�'
if replacement_char in metadata:
tmpl = "{self.path} could not be properly decoded in UTF-8"
Expand Down Expand Up @@ -2505,7 +2505,7 @@ def _handle_ns(packageName, path_item):
return subpath


def _rebuild_mod_path(orig_path, package_name, module: types.ModuleType):
def _rebuild_mod_path(orig_path, package_name, module: types.ModuleType) -> None:
"""
Rebuild module.__path__ ensuring that all entries are ordered
corresponding to their sys.path order
Expand Down Expand Up @@ -2624,7 +2624,7 @@ def null_ns_handler(
path_item: str | None,
packageName: str | None,
module: _ModuleLike | None,
):
) -> None:
return None


Expand All @@ -2635,7 +2635,7 @@ def null_ns_handler(
def normalize_path(filename: StrPath) -> str: ...
@overload
def normalize_path(filename: BytesPath) -> bytes: ...
def normalize_path(filename: StrOrBytesPath):
def normalize_path(filename: StrOrBytesPath) -> str | bytes:
"""Normalize a file/dir name for comparison purposes"""
return os.path.normcase(os.path.realpath(os.path.normpath(_cygwin_patch(filename))))

Expand Down Expand Up @@ -2691,7 +2691,7 @@ def _is_unpacked_egg(path):
)


def _set_parent_ns(packageName):
def _set_parent_ns(packageName) -> None:
parts = packageName.split('.')
name = parts.pop()
if parts:
Expand Down Expand Up @@ -3336,7 +3336,7 @@ def check_version_conflict(self):
" to sys.path" % (modname, fn, self.location),
)

def has_version(self):
def has_version(self) -> bool:
try:
self.version
except ValueError:
Expand Down Expand Up @@ -3552,7 +3552,7 @@ def ensure_directory(path: StrOrBytesPath) -> None:
os.makedirs(dirname, exist_ok=True)


def _bypass_ensure_directory(path):
def _bypass_ensure_directory(path) -> None:
"""Sandbox-bypassing version of ensure_directory()"""
if not WRITE_SUPPORT:
raise OSError('"os.mkdir" not supported on this platform.')
Expand Down Expand Up @@ -3658,7 +3658,7 @@ def _call_aside(f, *args, **kwargs):


@_call_aside
def _initialize(g=globals()):
def _initialize(g=globals()) -> None:
"Set up global resource manager (deliberately not state-saved)"
manager = ResourceManager()
g['_manager'] = manager
Expand All @@ -3670,7 +3670,7 @@ def _initialize(g=globals()):


@_call_aside
def _initialize_master_working_set():
def _initialize_master_working_set() -> None:
"""
Prepare the master working set and make the ``require()``
API available.
Expand Down
Loading