Skip to content

Commit

Permalink
Merge pull request #5932 from petr-tik/no4748-add-type-hints-to-inter…
Browse files Browse the repository at this point in the history
…nals

Added type hints to internals/utils
  • Loading branch information
pradyunsg committed Oct 30, 2018
2 parents 2ed581c + 55f6787 commit 5005769
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Empty file.
2 changes: 2 additions & 0 deletions src/pip/_internal/utils/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


def check_path_owner(path):
# type: (str) -> bool
# If we don't have a way to check the effective uid of this process, then
# we'll just assume that we own the directory.
if not hasattr(os, "geteuid"):
Expand All @@ -26,3 +27,4 @@ def check_path_owner(path):
return os.access(path, os.W_OK)
else:
previous, path = path, os.path.dirname(path)
return False # assume we don't own the path
9 changes: 9 additions & 0 deletions src/pip/_internal/utils/glibc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
import re
import warnings

from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Optional, Tuple # noqa: F401


def glibc_version_string():
# type: () -> Optional[str]
"Returns glibc version string, or None if not using glibc."

# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
Expand All @@ -32,6 +38,7 @@ def glibc_version_string():

# Separated out from have_compatible_glibc for easier unit testing
def check_glibc_version(version_str, required_major, minimum_minor):
# type: (str, int, int) -> bool
# Parse string and check against requested version.
#
# We use a regexp instead of str.split because we want to discard any
Expand All @@ -48,6 +55,7 @@ def check_glibc_version(version_str, required_major, minimum_minor):


def have_compatible_glibc(required_major, minimum_minor):
# type: (int, int) -> bool
version_str = glibc_version_string()
if version_str is None:
return False
Expand All @@ -72,6 +80,7 @@ def have_compatible_glibc(required_major, minimum_minor):
# misleading. Solution: instead of using platform, use our code that actually
# works.
def libc_ver():
# type: () -> Tuple[str, str]
"""Try to determine the glibc version
Returns a tuple of strings (lib, version) which default to empty strings
Expand Down

0 comments on commit 5005769

Please sign in to comment.