44import subprocess
55from collections import namedtuple
66from distutils .command .build_py import build_py as build_py_orig
7+ from typing import Dict
78
89from setuptools .command .sdist import sdist as sdist_orig
910
1920STATIC_VERSION_FILE = "_static_version.py"
2021
2122
22- def get_version (version_file = STATIC_VERSION_FILE ):
23+ def get_version (version_file : str = STATIC_VERSION_FILE ) -> str :
2324 version_info = get_static_version_info (version_file )
2425 version = version_info ["version" ]
2526 if version == "__use_git__" :
@@ -33,7 +34,7 @@ def get_version(version_file=STATIC_VERSION_FILE):
3334 return version
3435
3536
36- def get_static_version_info (version_file = STATIC_VERSION_FILE ):
37+ def get_static_version_info (version_file : str = STATIC_VERSION_FILE ) -> Dict [ str , str ] :
3738 version_info = {}
3839 with open (os .path .join (package_root , version_file ), "rb" ) as f :
3940 exec (f .read (), {}, version_info )
@@ -44,7 +45,7 @@ def version_is_from_git(version_file=STATIC_VERSION_FILE):
4445 return get_static_version_info (version_file )["version" ] == "__use_git__"
4546
4647
47- def pep440_format (version_info ) :
48+ def pep440_format (version_info : Version ) -> str :
4849 release , dev , labels = version_info
4950
5051 version_parts = [release ]
@@ -61,7 +62,7 @@ def pep440_format(version_info):
6162 return "" .join (version_parts )
6263
6364
64- def get_version_from_git ():
65+ def get_version_from_git () -> Version :
6566 try :
6667 p = subprocess .Popen (
6768 ["git" , "rev-parse" , "--show-toplevel" ],
0 commit comments