aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py3/_pytest/freeze_support.py
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-09 12:00:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 15:58:17 +0300
commit8e1413fed79d1e8036e65228af6c93399ccf5502 (patch)
tree502c9df7b2614d20541c7a2d39d390e9a51877cc /contrib/python/pytest/py3/_pytest/freeze_support.py
parent6b813c17d56d1d05f92c61ddc347d0e4d358fe85 (diff)
downloadydb-8e1413fed79d1e8036e65228af6c93399ccf5502.tar.gz
intermediate changes
ref:614ed510ddd3cdf86a8c5dbf19afd113397e0172
Diffstat (limited to 'contrib/python/pytest/py3/_pytest/freeze_support.py')
-rw-r--r--contrib/python/pytest/py3/_pytest/freeze_support.py45
1 files changed, 23 insertions, 22 deletions
diff --git a/contrib/python/pytest/py3/_pytest/freeze_support.py b/contrib/python/pytest/py3/_pytest/freeze_support.py
index f9d613a2b6..8b93ed5f7f 100644
--- a/contrib/python/pytest/py3/_pytest/freeze_support.py
+++ b/contrib/python/pytest/py3/_pytest/freeze_support.py
@@ -1,14 +1,14 @@
-"""
-Provides a function to report all internal modules for using freezing tools
-pytest
-"""
+"""Provides a function to report all internal modules for using freezing
+tools."""
+import types
+from typing import Iterator
+from typing import List
+from typing import Union
-def freeze_includes():
- """
- Returns a list of module names used by pytest that should be
- included by cx_freeze.
- """
+def freeze_includes() -> List[str]:
+ """Return a list of module names used by pytest that should be
+ included by cx_freeze."""
import py
import _pytest
@@ -17,25 +17,26 @@ def freeze_includes():
return result
-def _iter_all_modules(package, prefix=""):
- """
- Iterates over the names of all modules that can be found in the given
+def _iter_all_modules(
+ package: Union[str, types.ModuleType], prefix: str = "",
+) -> Iterator[str]:
+ """Iterate over the names of all modules that can be found in the given
package, recursively.
- Example:
- _iter_all_modules(_pytest) ->
- ['_pytest.assertion.newinterpret',
- '_pytest.capture',
- '_pytest.core',
- ...
- ]
+
+ >>> import _pytest
+ >>> list(_iter_all_modules(_pytest))
+ ['_pytest._argcomplete', '_pytest._code.code', ...]
"""
import os
import pkgutil
- if type(package) is not str:
- path, prefix = package.__path__[0], package.__name__ + "."
- else:
+ if isinstance(package, str):
path = package
+ else:
+ # Type ignored because typeshed doesn't define ModuleType.__path__
+ # (only defined on packages).
+ package_path = package.__path__ # type: ignore[attr-defined]
+ path, prefix = package_path[0], package.__name__ + "."
for _, name, is_package in pkgutil.iter_modules([path]):
if is_package:
for m in _iter_all_modules(os.path.join(path, name), prefix=name + "."):