Skip to content

Commit

Permalink
Format error text (#2890)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Mar 25, 2024
1 parent d4f70c6 commit 8afb4d4
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 13 deletions.
16 changes: 10 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,23 @@ Semantic versioning in our case means:
`WrongUnicodeEscapeViolation`, `RawStringNotNeededViolation`
- `wemake` output formatter now respects `NO_COLOR=1` option
to disable text highlighting. See https://no-color.org
- Add `ImportObjectCollisionViolation` to detect
- Adds `ImportObjectCollisionViolation` to detect
the same objects imported under different aliases
- Adds `reveal_locals` to the list of forbidden functions

### Bugfixes

- Fix `ForbiddenInlineIgnoreViolation` config parsing. #2590
- Fix `WrongEmptyLinesCountViolation` for func definitions with ellipsis. #2847
- Fix `WrongEmptyLinesCountViolation` for multiline implicit string concatination. #2787
- Fix `ObjectInBaseClassesListViolation` to include type name
- Fixes `ForbiddenInlineIgnoreViolation` config parsing. #2590
- Fixes `WrongEmptyLinesCountViolation` for func definitions with ellipsis. #2847
- Fixes `WrongEmptyLinesCountViolation` for multiline implicit string concatination. #2787
- Fixes `ObjectInBaseClassesListViolation`, `UnpythonicGetterSetterViolation`,
`ImplicitInConditionViolation`, `RedundantSubscriptViolation`,
`TooLongCompareViolation` to include better error details

### Misc

- Fixed multiple typos in docs
- Updates multiple`flake8-*` dependencies
- Fixes multiple typos in docs


## 0.18.0
Expand Down
5 changes: 4 additions & 1 deletion wemake_python_styleguide/violations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,12 @@ def message(self) -> str:
Conditionally formats the ``error_template`` if it is required.
"""
formatted = self.error_template.format(self._text)
if self._text and formatted == self.error_template: # pragma: no cover
raise ValueError('Error message was not formatted', self)
return '{0} {1}{2}'.format(
self.full_code,
self.error_template.format(self._text),
formatted,
self._postfix_information(),
)

Expand Down
2 changes: 1 addition & 1 deletion wemake_python_styleguide/violations/complexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ class TooLongCompareViolation(ASTViolation):
"""

error_template = 'Found too long compare'
error_template = 'Found too long compare: {0}'
code = 228


Expand Down
2 changes: 1 addition & 1 deletion wemake_python_styleguide/violations/consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ class SomeClassName(FirstParentClass, SecondParentClass, object): ...
"""

error_template = 'Found extra `object` in parent classes list'
error_template = 'Found extra `object` in parent classes list: {0}'
code = 315


Expand Down
2 changes: 1 addition & 1 deletion wemake_python_styleguide/violations/oop.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def get_attribute(self):
"""

error_template = 'Found unpythonic getter or setter'
error_template = 'Found unpythonic getter or setter: {0}'
code = 615


Expand Down
2 changes: 1 addition & 1 deletion wemake_python_styleguide/violations/refactoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ class ImplicitInConditionViolation(ASTViolation):
"""

code = 514
error_template = 'Found implicit `in` condition'
error_template = 'Found implicit `in` condition: {0}'
previous_codes = {336}


Expand Down
2 changes: 1 addition & 1 deletion wemake_python_styleguide/visitors/ast/subscripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _check_redundant_subscript(self, node: ast.Subscript) -> None:
if not (lower_ok and upper_ok and step_ok):
self.add_violation(
consistency.RedundantSubscriptViolation(
node, text=str(node),
node,
),
)

Expand Down
2 changes: 1 addition & 1 deletion wemake_python_styleguide/visitors/tokenize/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _check_bad_number_suffixes(self, token: tokenize.TokenInfo) -> None:
def _check_float_zeros(self, token: tokenize.TokenInfo) -> None:
if self._float_zero.match(token.string):
self.add_violation(
consistency.FloatZeroViolation(token, text=token.string),
consistency.FloatZeroViolation(token),
)


Expand Down

0 comments on commit 8afb4d4

Please sign in to comment.