From 84bc45eee2f46faaae457d7617b2baa01e7da3a0 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Wed, 27 Nov 2019 14:40:37 +0000 Subject: [PATCH] TYP: some types for util._print_versions (#29880) --- pandas/util/_print_versions.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pandas/util/_print_versions.py b/pandas/util/_print_versions.py index 289a32c51a916d..d1c74e85302451 100644 --- a/pandas/util/_print_versions.py +++ b/pandas/util/_print_versions.py @@ -6,14 +6,15 @@ import struct import subprocess import sys +from typing import List, Optional, Tuple, Union from pandas.compat._optional import VERSIONS, _get_version, import_optional_dependency -def get_sys_info(): - "Returns system information as a dict" +def get_sys_info() -> List[Tuple[str, Optional[Union[str, int]]]]: + "Returns system information as a list" - blob = [] + blob: List[Tuple[str, Optional[Union[str, int]]]] = [] # get full commit hash commit = None @@ -29,12 +30,7 @@ def get_sys_info(): pass else: if pipe.returncode == 0: - commit = so - try: - commit = so.decode("utf-8") - except ValueError: - pass - commit = commit.strip().strip('"') + commit = so.decode("utf-8").strip().strip('"') blob.append(("commit", commit)) @@ -99,6 +95,7 @@ def show_versions(as_json=False): mod = import_optional_dependency( modname, raise_on_missing=False, on_version="ignore" ) + ver: Optional[str] if mod: ver = _get_version(mod) else: