mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 06:20:08 +01:00
mypy pacification
This commit is contained in:
parent
b3c2dc03eb
commit
6aa16f7b37
3 changed files with 33 additions and 23 deletions
|
|
@ -83,7 +83,7 @@ def incr(old_version: str, release: str = None) -> None:
|
|||
new_version_nfo = parse.parse_version_info(new_version)
|
||||
|
||||
print("PyCalVer Version:", new_version)
|
||||
print("PEP440 Version:", new_version_nfo["pep440_version"])
|
||||
print("PEP440 Version:", new_version_nfo.pep440_version)
|
||||
|
||||
|
||||
@cli.command()
|
||||
|
|
@ -196,15 +196,14 @@ def bump(
|
|||
filepaths = set(file_patterns.keys())
|
||||
|
||||
_vcs = vcs.get_vcs()
|
||||
_vcs.assert_not_dirty(filepaths, allow_dirty)
|
||||
rewrite.rewrite(new_version, file_patterns, dry, verbose)
|
||||
|
||||
if dry:
|
||||
return
|
||||
|
||||
if not commit:
|
||||
return
|
||||
|
||||
if _vcs is None:
|
||||
log.warn("Version Control System not found, aborting commit.")
|
||||
else:
|
||||
_vcs.assert_not_dirty(filepaths, allow_dirty)
|
||||
|
||||
rewrite.rewrite(new_version, file_patterns, dry, verbose)
|
||||
|
||||
if dry or not commit or _vcs is None:
|
||||
return
|
||||
|
||||
# TODO (mb 2018-09-04): add files and commit
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ def ord_val(lex_id: str) -> int:
|
|||
return int(lex_id[1:], 10)
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
_curr_id = "01"
|
||||
print(f"{'lexical':<13} {'numerical':>12}")
|
||||
|
||||
|
|
|
|||
|
|
@ -21,18 +21,29 @@ log = logging.getLogger("pycalver.vcs")
|
|||
|
||||
class BaseVCS:
|
||||
|
||||
@classmethod
|
||||
def commit(cls, message):
|
||||
f = tempfile.NamedTemporaryFile("wb", delete=False)
|
||||
f.write(message.encode("utf-8"))
|
||||
f.close()
|
||||
cmd = cls._COMMIT_COMMAND + [f.name]
|
||||
env_items = list(os.environ.items()) + [(b"HGENCODING", b"utf-8")]
|
||||
sp.check_output(cmd, env=dict(env_items))
|
||||
os.unlink(f.name)
|
||||
_TEST_USABLE_COMMAND: typ.List[str]
|
||||
_COMMIT_COMMAND: typ.List[str]
|
||||
_STATUS_COMMAND: typ.List[str]
|
||||
|
||||
@classmethod
|
||||
def is_usable(cls):
|
||||
def commit(cls, message: str) -> None:
|
||||
message_data = message.encode("utf-8")
|
||||
|
||||
tmp_file = tempfile.NamedTemporaryFile("wb", delete=False)
|
||||
|
||||
with tmp_file as fh:
|
||||
fh.write(message_data)
|
||||
|
||||
cmd = cls._COMMIT_COMMAND + [tmp_file.name]
|
||||
env = os.environ.copy()
|
||||
# TODO (mb 2018-09-04): check that this works on py27,
|
||||
# might need to be bytes there, idk.
|
||||
env["HGENCODING"] = "utf-8"
|
||||
sp.check_output(cmd, env=env)
|
||||
os.unlink(tmp_file.name)
|
||||
|
||||
@classmethod
|
||||
def is_usable(cls) -> bool:
|
||||
try:
|
||||
return sp.call(
|
||||
cls._TEST_USABLE_COMMAND,
|
||||
|
|
@ -46,7 +57,7 @@ class BaseVCS:
|
|||
raise
|
||||
|
||||
@classmethod
|
||||
def dirty_files(cls):
|
||||
def dirty_files(cls) -> typ.List[str]:
|
||||
status_output = sp.check_output(cls._STATUS_COMMAND)
|
||||
return [
|
||||
line.decode("utf-8")[2:].strip()
|
||||
|
|
@ -107,7 +118,7 @@ class Mercurial(BaseVCS):
|
|||
VCS = [Git, Mercurial]
|
||||
|
||||
|
||||
def get_vcs():
|
||||
def get_vcs() -> typ.Optional[typ.Type[BaseVCS]]:
|
||||
for vcs in VCS:
|
||||
if vcs.is_usable():
|
||||
return vcs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue