15
15
16
16
def _exec (cmd ): # type: (str) -> List[str]
17
17
try :
18
- stdout = subprocess .check_output (
19
- cmd , shell = True , universal_newlines = True # nosec
20
- )
18
+ stdout = subprocess .check_output (cmd , shell = True , universal_newlines = True ) # nosec
21
19
except subprocess .CalledProcessError as e :
22
20
stdout = e .output
23
21
lines = stdout .splitlines ()
@@ -64,14 +62,14 @@ def get_tag(): # type: () -> Optional[str]
64
62
65
63
66
64
def get_sha (name = "HEAD" ): # type: (str) -> Optional[str]
67
- sha = _exec (f 'git rev-list -n 1 "{ name } "' )
65
+ sha = _exec ('git rev-list -n 1 "{}"' . format ( name ) )
68
66
if sha :
69
67
return sha [0 ]
70
68
return None
71
69
72
70
73
71
def get_latest_file_commit (path ): # type: (str) -> Optional[str]
74
- sha = _exec (f 'git log -n 1 --pretty=format:%H -- "{ path } "' )
72
+ sha = _exec ('git log -n 1 --pretty=format:%H -- "{}"' . format ( path ) )
75
73
if sha :
76
74
return sha [0 ]
77
75
return None
@@ -85,7 +83,7 @@ def is_dirty(): # type: () -> bool
85
83
86
84
87
85
def count_since (name ): # type: (str) -> Optional[int]
88
- res = _exec (f 'git rev-list --count HEAD "^{ name } "' )
86
+ res = _exec ('git rev-list --count HEAD "^{}"' . format ( name ) )
89
87
if res :
90
88
return int (res [0 ])
91
89
return None
@@ -109,9 +107,7 @@ def parse_config(dist, _, value): # type: (Distribution, Any, Any) -> None
109
107
starting_version = value .get ("starting_version" , DEFAULT_STARTING_VERSION )
110
108
version_callback = value .get ("version_callback" , None )
111
109
version_file = value .get ("version_file" , None )
112
- count_commits_from_version_file = value .get (
113
- "count_commits_from_version_file" , False
114
- )
110
+ count_commits_from_version_file = value .get ("count_commits_from_version_file" , False )
115
111
branch_formatter = value .get ("branch_formatter" , None )
116
112
117
113
version = version_from_git (
@@ -191,9 +187,7 @@ def version_from_git(
191
187
else :
192
188
t = template
193
189
194
- version = t .format (
195
- sha = full_sha [:8 ], tag = tag , ccount = ccount , branch = branch , full_sha = full_sha
196
- )
190
+ version = t .format (sha = full_sha [:8 ], tag = tag , ccount = ccount , branch = branch , full_sha = full_sha )
197
191
198
192
# Ensure local version label only contains permitted characters
199
193
public , sep , local = version .partition ("+" )
0 commit comments