FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-108455: peg_generator: enable mypy's `--warn-unreachable` setting and `redundant-expr` error code by AlexWaygood · Pull Request #109160 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ini  (1) .py  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
14 changes: 11 additions & 3 deletions Tools/peg_generator/mypy.ini
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ python_version = 3.10

# Be strict...
strict = True
enable_error_code = truthy-bool,ignore-without-code
warn_unreachable = True
enable_error_code = truthy-bool,ignore-without-code,redundant-expr

# except for a few settings that can't yet be enabled:
# This causes *many* false positives on the peg_generator
# due to pegen.grammar.GrammarVisitor returning Any from visit() and generic_visit().
# It would be possible to workaround the false positives using asserts,
# but it would be pretty tedious, and probably isn't worth it.
warn_return_any = False
warn_unreachable = False

# Not all of the strictest settings can be enabled
# on generated Python code yet:
[mypy-pegen.grammar_parser.*]
disable_error_code = redundant-expr
2 changes: 0 additions & 2 deletions Tools/peg_generator/pegen/ast_dump.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,4 @@ def _format(node: Any, level: int = 0) -> Tuple[str, bool]:

if all(cls.__name__ != "AST" for cls in node.__class__.__mro__):
raise TypeError("expected AST, got %r" % node.__class__.__name__)
if indent is not None and not isinstance(indent, str):
indent = " " * indent
return _format(node)[0]
6 changes: 2 additions & 4 deletions Tools/peg_generator/pegen/grammar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ def __str__(self) -> str:
return self.value

def __iter__(self) -> Iterable[str]:
if False:
yield
yield from ()


class NameLeaf(Leaf):
Expand Down Expand Up @@ -335,8 +334,7 @@ def __str__(self) -> str:
return f"~"

def __iter__(self) -> Iterator[Tuple[str, str]]:
if False:
yield
yield from ()

def __eq__(self, other: object) -> bool:
if not isinstance(other, Cut):
Expand Down

Back | FazBrowse Home | New Git URL