enable pylint in ci

This commit is contained in:
Manuel Barkhau 2020-07-19 19:07:30 +00:00
parent 47b451ff9f
commit 1bcf308661
5 changed files with 211 additions and 7 deletions

View file

@ -348,13 +348,13 @@ lint_pylint:
@mkdir -p "reports/";
@printf "pylint ..\n";
@$(DEV_ENV)/bin/pylint --rcfile=setup.cfg src/ test/
@$(DEV_ENV)/bin/pylint-ignore --rcfile=setup.cfg src/ test/
@printf "\e[1F\e[9C ok\n"
## Run flake8 linter and check for fmt
.PHONY: lint
lint: lint_isort lint_sjfmt lint_flake8
lint: lint_isort lint_sjfmt lint_flake8 lint_pylint
## Run mypy type checker

204
pylint-ignore.md Normal file
View file

@ -0,0 +1,204 @@
# `pylint-ignore`
**WARNING: This file is programatically generated.**
This file is parsed by `pylint-ignore` to determine which `pylint`
messages 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`
## File test/test_version.py - Line 145 - E1101 (no-member)
- `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
```
## File src/pycalver/rewrite.py - Line 168 - E1101 (no-member)
- `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)
- `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:
...
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)
```
## File src/pycalver/cli.py - Line 78 - W0603 (global-statement)
- `message: Using the global statement`
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
- `date : 2020-07-19T18:50:33`
```
76: def cli(verbose: int = 0) -> None:
77: """Automatically update PyCalVer version strings on python projects."""
> 78: global _VERBOSE
79: _VERBOSE = verbose
80:
```
## File src/pycalver/vcs.py - Line 104 - 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:
...
102: return False
103: return True
> 104: except Exception:
105: return False
106:
```
## File src/pycalver/cli.py - Line 292 - W0703 (broad-except)
- `message: Catching too general exception Exception`
- `author : Manuel Barkhau <mbarkhau@gmail.com>`
- `date : 2020-07-19T18:50:33`
```
289: def _try_print_diff(cfg: config.Config, new_version: str) -> None:
...
290: try:
291: _print_diff(cfg, new_version)
> 292: except Exception as ex:
293: logger.error(str(ex))
294: sys.exit(1)
```

View file

@ -109,7 +109,7 @@ README.md =
[tool:pylint]
score = yes
score = no
# pylint-ignore only works with jobs = 1
jobs = 1

View file

@ -185,7 +185,7 @@ def _replace_pattern_parts(pattern: str) -> str:
return pattern
def _compile_pattern(pattern: str) -> str:
def compile_pattern_str(pattern: str) -> str:
for char, escaped in PATTERN_ESCAPES:
pattern = pattern.replace(char, escaped)
@ -193,7 +193,7 @@ def _compile_pattern(pattern: str) -> str:
def compile_pattern(pattern: str) -> typ.Pattern[str]:
pattern_str = _compile_pattern(pattern)
pattern_str = compile_pattern_str(pattern)
return re.compile(pattern_str)

View file

@ -81,8 +81,8 @@ def rewrite_lines(
if non_matched_patterns:
for non_matched_pattern in non_matched_patterns:
logger.error(f"No match for pattern '{non_matched_pattern}'")
compiled_pattern = patterns._compile_pattern(non_matched_pattern)
logger.error(f"Pattern compiles to regex '{compiled_pattern}'")
compiled_pattern_str = patterns.compile_pattern_str(non_matched_pattern)
logger.error(f"Pattern compiles to regex '{compiled_pattern_str}'")
raise NoPatternMatch("Invalid pattern(s)")
else:
return new_lines