Skip to content

Commit 2118a55

Browse files
authored
pkg_resources: Clarify some methods return bytes, not str
1 parent 8c45d6e commit 2118a55

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pkg_resources/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ def get_resource_stream(self, manager, resource_name):
566566
567567
`manager` must be an ``IResourceManager``"""
568568

569-
def get_resource_string(self, manager, resource_name):
570-
"""Return a string containing the contents of `resource_name`
569+
def get_resource_string(self, manager, resource_name) -> bytes:
570+
"""Return a bytes string containing the contents of `resource_name`
571571
572572
`manager` must be an ``IResourceManager``"""
573573

@@ -1203,8 +1203,8 @@ def resource_stream(self, package_or_requirement, resource_name):
12031203
self, resource_name
12041204
)
12051205

1206-
def resource_string(self, package_or_requirement, resource_name):
1207-
"""Return specified resource as a string"""
1206+
def resource_string(self, package_or_requirement, resource_name) -> bytes:
1207+
"""Return specified resource as a bytes string"""
12081208
return get_provider(package_or_requirement).get_resource_string(
12091209
self, resource_name
12101210
)
@@ -1479,7 +1479,7 @@ def get_resource_filename(self, manager, resource_name):
14791479
def get_resource_stream(self, manager, resource_name):
14801480
return io.BytesIO(self.get_resource_string(manager, resource_name))
14811481

1482-
def get_resource_string(self, manager, resource_name):
1482+
def get_resource_string(self, manager, resource_name) -> bytes:
14831483
return self._get(self._fn(self.module_path, resource_name))
14841484

14851485
def has_resource(self, resource_name):
@@ -1649,7 +1649,7 @@ def _validate_resource_path(path):
16491649
DeprecationWarning,
16501650
)
16511651

1652-
def _get(self, path):
1652+
def _get(self, path) -> bytes:
16531653
if hasattr(self.loader, 'get_data'):
16541654
return self.loader.get_data(path)
16551655
raise NotImplementedError(
@@ -1706,7 +1706,7 @@ def _listdir(self, path):
17061706
def get_resource_stream(self, manager, resource_name):
17071707
return open(self._fn(self.module_path, resource_name), 'rb')
17081708

1709-
def _get(self, path):
1709+
def _get(self, path) -> bytes:
17101710
with open(path, 'rb') as stream:
17111711
return stream.read()
17121712

@@ -1731,8 +1731,8 @@ class EmptyProvider(NullProvider):
17311731

17321732
_isdir = _has = lambda self, path: False
17331733

1734-
def _get(self, path):
1735-
return ''
1734+
def _get(self, path) -> bytes:
1735+
return b''
17361736

17371737
def _listdir(self, path):
17381738
return []

0 commit comments

Comments
 (0)