mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 14:30:09 +01:00
cli -> __main__ refactor
This commit is contained in:
parent
4caece2817
commit
75563672b4
3 changed files with 169 additions and 154 deletions
319
pylint-ignore.md
319
pylint-ignore.md
|
|
@ -1,204 +1,219 @@
|
|||
# `pylint-ignore`
|
||||
# Pylint-Ignore
|
||||
|
||||
**WARNING: This file is programatically generated.**
|
||||
|
||||
This file is parsed by `pylint-ignore` to determine which `pylint`
|
||||
messages should be ignored.
|
||||
This file is parsed by [`pylint-ignore`](https://pypi.org/project/pylint-ignore/)
|
||||
to determine which
|
||||
[Pylint messages](https://pylint.pycqa.org/en/stable/technical_reference/features.html)
|
||||
should be ignored.
|
||||
|
||||
- Do not edit this file manually.
|
||||
- To update, use `pylint-ignore --update-ignorefile`
|
||||
|
||||
The recommended approach to using `pylint-ignore` is:
|
||||
|
||||
- If a message refers to a valid issue, update your code rather than
|
||||
ignoring the message.
|
||||
- If a message should *always* be ignored (globally), then to do so
|
||||
via the usual `pylintrc` or `setup.cfg` files rather than this
|
||||
`pylint-ignore.md` file.
|
||||
- If a message is a false positive, add a comment of this form to your code:
|
||||
`# pylint:disable=<symbol> ; explanation why this is a false positive`
|
||||
1. If a message refers to a valid issue, update your code rather than
|
||||
ignoring the message.
|
||||
2. If a message should *always* be ignored (globally), then to do so
|
||||
via the usual `pylintrc` or `setup.cfg` files rather than this
|
||||
`pylint-ignore.md` file.
|
||||
3. If a message is a false positive, add a comment of this form to your code:
|
||||
`# pylint:disable=<symbol> ; explain why this is a false positive`
|
||||
|
||||
|
||||
## File test/test_version.py - Line 145 - E1101 (no-member)
|
||||
# Overview
|
||||
|
||||
- `message: Class 'VersionInfo' has no '_fields' member`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T19:06:44`
|
||||
|
||||
```
|
||||
134: def test_part_field_mapping():
|
||||
...
|
||||
143:
|
||||
144: a_fields = set(version.PATTERN_PART_FIELDS.values())
|
||||
> 145: b_fields = set(version.VersionInfo._fields)
|
||||
146:
|
||||
147: assert a_fields == b_fields
|
||||
```
|
||||
- [W0511: fixme (5x)](#w0511-fixme)
|
||||
- [W0603: global-statement (1x)](#w0603-global-statement)
|
||||
- [W0613: unused-argument (1x)](#w0613-unused-argument)
|
||||
- [W0703: broad-except (2x)](#w0703-broad-except)
|
||||
- [C0412: ungrouped-imports (2x)](#c0412-ungrouped-imports)
|
||||
|
||||
|
||||
## File src/pycalver/rewrite.py - Line 168 - E1101 (no-member)
|
||||
# W0511: fixme
|
||||
|
||||
- `message: Instance of 'RewrittenFileData' has no '_replace' member`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T18:50:33`
|
||||
|
||||
```
|
||||
138: def iter_rewritten(
|
||||
...
|
||||
166:
|
||||
167: rfd = rfd_from_content(pattern_strs, new_vinfo, content)
|
||||
> 168: yield rfd._replace(path=str(file_path))
|
||||
169:
|
||||
170:
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/rewrite.py - Line 217 - E1101 (no-member)
|
||||
|
||||
- `message: Instance of 'RewrittenFileData' has no '_replace' member`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T18:50:33`
|
||||
|
||||
```
|
||||
189: def diff(new_vinfo: version.VersionInfo, file_patterns: config.PatternsByGlob) -> str:
|
||||
...
|
||||
215: raise NoPatternMatch(errmsg)
|
||||
216:
|
||||
> 217: rfd = rfd._replace(path=str(file_path))
|
||||
218: lines = diff_lines(rfd)
|
||||
219: if len(lines) == 0:
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/version.py - Line 235 - E1101 (no-member)
|
||||
|
||||
- `message: Class 'CalendarInfo' has no '_fields' member`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T18:50:33`
|
||||
|
||||
```
|
||||
221: def _is_calver(nfo: typ.Union[CalendarInfo, VersionInfo]) -> bool:
|
||||
...
|
||||
233: False
|
||||
234: """
|
||||
> 235: for field in CalendarInfo._fields:
|
||||
236: maybe_val: typ.Any = getattr(nfo, field, None)
|
||||
237: if isinstance(maybe_val, int):
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/version.py - Line 481 - E1101 (no-member)
|
||||
|
||||
- `message: Instance of 'CalendarInfo' has no '_asdict' member`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T18:50:33`
|
||||
|
||||
```
|
||||
454: def incr(
|
||||
...
|
||||
479:
|
||||
480: if old_date <= cur_date:
|
||||
> 481: cur_vinfo = cur_vinfo._replace(**cur_cal_nfo._asdict())
|
||||
482: else:
|
||||
483: logger.warning(f"Version appears to be from the future '{old_version}'")
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/version.py - Line 481 - E1101 (no-member)
|
||||
|
||||
- `message: Instance of 'VersionInfo' has no '_replace' member`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T18:50:33`
|
||||
|
||||
```
|
||||
454: def incr(
|
||||
...
|
||||
479:
|
||||
480: if old_date <= cur_date:
|
||||
> 481: cur_vinfo = cur_vinfo._replace(**cur_cal_nfo._asdict())
|
||||
482: else:
|
||||
483: logger.warning(f"Version appears to be from the future '{old_version}'")
|
||||
```
|
||||
|
||||
|
||||
## File test/util.py - Line 10 - R0903 (too-few-public-methods)
|
||||
|
||||
- `message: Too few public methods (1/2)`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T19:06:44`
|
||||
|
||||
```
|
||||
8:
|
||||
9:
|
||||
> 10: class Shell:
|
||||
11: def __init__(self, cwd):
|
||||
12: self.cwd = cwd
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/vcs.py - Line 75 - W0511 (fixme)
|
||||
## File src/pycalver/vcs.py - Line 78 - W0511 (fixme)
|
||||
|
||||
- `message: TODO (mb 2018-11-15): Detect encoding of output?`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T18:50:33`
|
||||
|
||||
```
|
||||
65: def __call__(self, cmd_name: str, env: Env = None, **kwargs: str) -> str:
|
||||
68: def __call__(self, cmd_name: str, env: Env = None, **kwargs: str) -> str:
|
||||
...
|
||||
73: output_data: bytes = sp.check_output(cmd_str.split(), env=env, stderr=sp.STDOUT)
|
||||
74:
|
||||
> 75: # TODO (mb 2018-11-15): Detect encoding of output?
|
||||
76: _encoding = "utf-8"
|
||||
77: return output_data.decode(_encoding)
|
||||
76: output_data: bytes = sp.check_output(cmd_str.split(), env=env, stderr=sp.STDOUT)
|
||||
77:
|
||||
> 78: # TODO (mb 2018-11-15): Detect encoding of output?
|
||||
79: _encoding = "utf-8"
|
||||
80: return output_data.decode(_encoding)
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/cli.py - Line 78 - W0603 (global-statement)
|
||||
## File src/pycalver2/version.py - Line 184 - W0511 (fixme)
|
||||
|
||||
- `message: TODO (mb 2020-09-05): pytag`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-09-05T14:30:17`
|
||||
|
||||
```
|
||||
176: def _parse_field_values(field_values: FieldValues) -> VersionInfo:
|
||||
...
|
||||
182: tag = TAG_ALIASES.get(tag, tag)
|
||||
183: assert tag is not None
|
||||
> 184: # TODO (mb 2020-09-05): pytag
|
||||
185: pytag = ""
|
||||
186:
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/__main__.py - Line 220 - W0511 (fixme)
|
||||
|
||||
- `message: TODO (mb 2020-09-05): version switch`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-09-05T14:30:17`
|
||||
|
||||
```
|
||||
200: def _bump(
|
||||
...
|
||||
218:
|
||||
219: try:
|
||||
> 220: # TODO (mb 2020-09-05): version switch
|
||||
221: v1cli.rewrite(cfg, new_version)
|
||||
222: v2cli.rewrite(cfg, new_version)
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/__main__.py - Line 274 - W0511 (fixme)
|
||||
|
||||
- `message: TODO (mb 2020-09-05): version switch`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-09-05T14:30:17`
|
||||
|
||||
```
|
||||
272:
|
||||
273: def _update_cfg_from_vcs(cfg: config.Config, fetch: bool) -> config.Config:
|
||||
> 274: # TODO (mb 2020-09-05): version switch
|
||||
275: all_tags = vcs.get_tags(fetch=fetch)
|
||||
276:
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/__main__.py - Line 378 - W0511 (fixme)
|
||||
|
||||
- `message: # TODO (mb 2020-09-05): format from config`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-09-05T14:30:17`
|
||||
|
||||
```
|
||||
324: def bump(
|
||||
...
|
||||
376: return
|
||||
377:
|
||||
> 378: # # TODO (mb 2020-09-05): format from config
|
||||
379: # commit_message_kwargs = {
|
||||
380: # new_version
|
||||
```
|
||||
|
||||
|
||||
# W0603: global-statement
|
||||
|
||||
## File src/pycalver/__main__.py - Line 75 - W0603 (global-statement)
|
||||
|
||||
- `message: Using the global statement`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T18:50:33`
|
||||
- `date : 2020-09-05T14:30:17`
|
||||
|
||||
```
|
||||
76: def cli(verbose: int = 0) -> None:
|
||||
77: """Automatically update PyCalVer version strings on python projects."""
|
||||
> 78: global _VERBOSE
|
||||
79: _VERBOSE = verbose
|
||||
80:
|
||||
73: def cli(verbose: int = 0) -> None:
|
||||
74: """Automatically update PyCalVer version strings on python projects."""
|
||||
> 75: global _VERBOSE
|
||||
76: _VERBOSE = verbose
|
||||
77:
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/vcs.py - Line 104 - W0703 (broad-except)
|
||||
# W0613: unused-argument
|
||||
|
||||
## File src/pycalver2/version.py - Line 431 - W0613 (unused-argument)
|
||||
|
||||
- `message: Unused argument 'kwargs'`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-09-05T14:30:17`
|
||||
|
||||
```
|
||||
429:
|
||||
430:
|
||||
> 431: def _compile_format_template(pattern: str, kwargs: TemplateKwargs) -> str:
|
||||
432: # NOTE (mb 2020-09-04): Some parts are optional, we need the kwargs to
|
||||
433: # determine if part is set to its zero value
|
||||
```
|
||||
|
||||
|
||||
# W0703: broad-except
|
||||
|
||||
## File src/pycalver/vcs.py - Line 107 - W0703 (broad-except)
|
||||
|
||||
- `message: Catching too general exception Exception`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T18:50:33`
|
||||
|
||||
```
|
||||
98: def has_remote(self) -> bool:
|
||||
101: def has_remote(self) -> bool:
|
||||
...
|
||||
102: return False
|
||||
103: return True
|
||||
> 104: except Exception:
|
||||
105: return False
|
||||
106:
|
||||
105: return False
|
||||
106: return True
|
||||
> 107: except Exception:
|
||||
108: return False
|
||||
109:
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/cli.py - Line 292 - W0703 (broad-except)
|
||||
## File src/pycalver/__main__.py - Line 223 - W0703 (broad-except)
|
||||
|
||||
- `message: Catching too general exception Exception`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-07-19T18:50:33`
|
||||
- `date : 2020-09-05T14:30:17`
|
||||
|
||||
```
|
||||
289: def _try_print_diff(cfg: config.Config, new_version: str) -> None:
|
||||
200: def _bump(
|
||||
...
|
||||
290: try:
|
||||
291: _print_diff(cfg, new_version)
|
||||
> 292: except Exception as ex:
|
||||
293: logger.error(str(ex))
|
||||
294: sys.exit(1)
|
||||
221: v1cli.rewrite(cfg, new_version)
|
||||
222: v2cli.rewrite(cfg, new_version)
|
||||
> 223: except Exception as ex:
|
||||
224: logger.error(str(ex))
|
||||
225: sys.exit(1)
|
||||
```
|
||||
|
||||
|
||||
# C0412: ungrouped-imports
|
||||
|
||||
## File src/pycalver/__main__.py - Line 21 - C0412 (ungrouped-imports)
|
||||
|
||||
- `message: Imports from package pycalver are not grouped`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-09-05T14:30:17`
|
||||
|
||||
```
|
||||
19: import pycalver.cli as v1cli
|
||||
20: import pycalver2.cli as v2cli
|
||||
> 21: import pycalver.version as v1version
|
||||
22: import pycalver2.version as v2version
|
||||
23: from pycalver import vcs
|
||||
```
|
||||
|
||||
|
||||
## File src/pycalver/__main__.py - Line 22 - C0412 (ungrouped-imports)
|
||||
|
||||
- `message: Imports from package pycalver2 are not grouped`
|
||||
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
|
||||
- `date : 2020-09-05T14:30:17`
|
||||
|
||||
```
|
||||
20: import pycalver2.cli as v2cli
|
||||
21: import pycalver.version as v1version
|
||||
> 22: import pycalver2.version as v2version
|
||||
23: from pycalver import vcs
|
||||
24: from pycalver import config
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -91,7 +91,7 @@ setuptools.setup(
|
|||
install_requires=install_requires,
|
||||
entry_points="""
|
||||
[console_scripts]
|
||||
pycalver=pycalver.cli:cli
|
||||
pycalver=pycalver.__main__:cli
|
||||
""",
|
||||
python_requires=">=2.7",
|
||||
zip_safe=True,
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class Project:
|
|||
for path_parts in FIXTURE_PATH_PARTS:
|
||||
maybe_file_path = self.dir.joinpath(*path_parts)
|
||||
if maybe_file_path.exists():
|
||||
self.shell(f"{cmd} add {str(maybe_file_path)}")
|
||||
self.shell(cmd + " add " + str(maybe_file_path))
|
||||
added_file_paths.append(maybe_file_path)
|
||||
|
||||
assert len(added_file_paths) >= 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue