-
-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
我先 Merge 了,然后按照保存一个个改旧的 Typing 问题吧。
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
quick script to write mypy errors to github comments | ||
""" | ||
import re | ||
import sys | ||
|
||
|
||
MYPY_REGEX = ( | ||
r"^(\w:)?(?P<file>[^:]+):(?P<line>\d+):((?P<col>\d+):)?" | ||
r"\s*(?P<type>[^:]+):\s*(?P<msg>.+)" | ||
) | ||
MYPY = re.compile(MYPY_REGEX) | ||
|
||
|
||
def error( | ||
file: str, line: int = 0, col: int = 0, message: str = "error", warn: bool = False | ||
) -> None: | ||
"""write an error to stdout""" | ||
kind = "warning" if warn else "error" | ||
print(f"::{kind} file={file},line={line},col={col}::{message}") | ||
|
||
|
||
def main(file_path: str) -> None: | ||
"""read the given file, and print errors""" | ||
data = "" | ||
with open(file_path) as file: | ||
data = file.read() | ||
|
||
for line in data.split("\n"): | ||
match = MYPY.match(line) | ||
if match: | ||
values = match.groupdict() | ||
error( | ||
values["file"], | ||
line=int(values["line"]), | ||
col=int(values["col"]), | ||
message=values["msg"], | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("you must specify a json file path!") | ||
sys.exit(1) | ||
file_path = sys.argv[1] | ||
main(file_path) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# MyPy config file | ||
# File reference here - http://mypy.readthedocs.io/en/latest/config_file.html#config-file | ||
|
||
[mypy] | ||
warn_redundant_casts = True | ||
warn_unused_ignores = True | ||
|
||
# Needed because of bug in MyPy | ||
disallow_subclassing_any = False | ||
|
||
[mypy-*] | ||
disallow_untyped_calls = True | ||
disallow_untyped_defs = True | ||
check_untyped_defs = True | ||
warn_return_any = True | ||
no_implicit_optional = True | ||
strict_optional = True | ||
ignore_missing_imports = True |