mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 22:40:09 +01:00
better mypy coverage
This commit is contained in:
parent
a9e662d245
commit
44d2dceaf8
3 changed files with 21 additions and 13 deletions
|
|
@ -190,7 +190,7 @@ def init(verbose: int = 0, dry: bool = False) -> None:
|
||||||
config.write_content(ctx)
|
config.write_content(ctx)
|
||||||
|
|
||||||
|
|
||||||
def _assert_not_dirty(_vcs: vcs.VCS, filepaths: typ.Set[str], allow_dirty: bool):
|
def _assert_not_dirty(_vcs: vcs.VCS, filepaths: typ.Set[str], allow_dirty: bool) -> None:
|
||||||
dirty_files = _vcs.status(required_files=filepaths)
|
dirty_files = _vcs.status(required_files=filepaths)
|
||||||
|
|
||||||
if dirty_files:
|
if dirty_files:
|
||||||
|
|
|
||||||
|
|
@ -177,8 +177,8 @@ def _parse_cfg(cfg_buffer: typ.IO[str]) -> RawConfig:
|
||||||
|
|
||||||
|
|
||||||
def _parse_toml(cfg_buffer: typ.IO[str]) -> RawConfig:
|
def _parse_toml(cfg_buffer: typ.IO[str]) -> RawConfig:
|
||||||
raw_full_cfg = toml.load(cfg_buffer)
|
raw_full_cfg: typ.Any = toml.load(cfg_buffer)
|
||||||
raw_cfg = raw_full_cfg.get('pycalver', {})
|
raw_cfg : RawConfig = raw_full_cfg.get('pycalver', {})
|
||||||
|
|
||||||
for option, default_val in BOOL_OPTIONS.items():
|
for option, default_val in BOOL_OPTIONS.items():
|
||||||
raw_cfg[option] = raw_cfg.get(option, default_val)
|
raw_cfg[option] = raw_cfg.get(option, default_val)
|
||||||
|
|
@ -299,6 +299,8 @@ def parse(ctx: ProjectContext) -> MaybeConfig:
|
||||||
else:
|
else:
|
||||||
cfg_path = str(ctx.config_filepath)
|
cfg_path = str(ctx.config_filepath)
|
||||||
|
|
||||||
|
raw_cfg: RawConfig
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with ctx.config_filepath.open(mode="rt", encoding="utf-8") as fh:
|
with ctx.config_filepath.open(mode="rt", encoding="utf-8") as fh:
|
||||||
if ctx.config_format == 'toml':
|
if ctx.config_format == 'toml':
|
||||||
|
|
@ -309,7 +311,7 @@ def parse(ctx: ProjectContext) -> MaybeConfig:
|
||||||
err_msg = "Invalid config_format='{ctx.config_format}'"
|
err_msg = "Invalid config_format='{ctx.config_format}'"
|
||||||
raise RuntimeError(err_msg)
|
raise RuntimeError(err_msg)
|
||||||
|
|
||||||
cfg = _parse_config(raw_cfg)
|
cfg: Config = _parse_config(raw_cfg)
|
||||||
|
|
||||||
if cfg_path not in cfg.file_patterns:
|
if cfg_path not in cfg.file_patterns:
|
||||||
fh.seek(0)
|
fh.seek(0)
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,8 @@ def _is_calver(nfo: typ.Union[CalendarInfo, VersionInfo]) -> bool:
|
||||||
False
|
False
|
||||||
"""
|
"""
|
||||||
for field in CalendarInfo._fields:
|
for field in CalendarInfo._fields:
|
||||||
if isinstance(getattr(nfo, field, None), int):
|
maybe_val: typ.Any = getattr(nfo, field, None)
|
||||||
|
if isinstance(maybe_val, int):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
@ -399,19 +400,24 @@ def format_version(vinfo: VersionInfo, pattern: str) -> str:
|
||||||
for part_name, full_part_format in patterns.FULL_PART_FORMATS.items():
|
for part_name, full_part_format in patterns.FULL_PART_FORMATS.items():
|
||||||
full_pattern = full_pattern.replace("{" + part_name + "}", full_part_format)
|
full_pattern = full_pattern.replace("{" + part_name + "}", full_part_format)
|
||||||
|
|
||||||
kw = vinfo._asdict()
|
kw: typ.Dict[str, typ.Union[str, int, None]] = vinfo._asdict()
|
||||||
if kw['tag'] == 'final':
|
|
||||||
|
tag = vinfo.tag
|
||||||
|
if tag == 'final':
|
||||||
kw['release' ] = ""
|
kw['release' ] = ""
|
||||||
kw['pep440_tag'] = ""
|
kw['pep440_tag'] = ""
|
||||||
else:
|
else:
|
||||||
kw['release' ] = "-" + kw['tag']
|
kw['release' ] = "-" + tag
|
||||||
kw['pep440_tag'] = PEP440_TAGS[kw['tag']] + "0"
|
kw['pep440_tag'] = PEP440_TAGS[tag] + "0"
|
||||||
|
|
||||||
kw['release_tag'] = kw['tag']
|
kw['release_tag'] = tag
|
||||||
|
|
||||||
kw['yy' ] = str(kw['year'])[-2:]
|
year = vinfo.year
|
||||||
kw['yyyy'] = kw['year']
|
if year:
|
||||||
kw['BID' ] = int(kw['bid'], 10)
|
kw['yy' ] = str(year)[-2:]
|
||||||
|
kw['yyyy'] = year
|
||||||
|
|
||||||
|
kw['BID'] = int(vinfo.bid, 10)
|
||||||
|
|
||||||
for part_name, field in ID_FIELDS_BY_PART.items():
|
for part_name, field in ID_FIELDS_BY_PART.items():
|
||||||
val = kw[field]
|
val = kw[field]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue