Skip to content

Commit

Permalink
mypy: Enable strict mode and lots of errors.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Oct 27, 2023
1 parent 9159a9f commit 0d68c1f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
src_paths = ["."]
profile = "black"

[tool.mypy]
strict = true
enable_error_code = [
"redundant-self",
"redundant-expr",
"possibly-undefined",
"truthy-bool",
"truthy-iterable",
"ignore-without-code",
"unused-awaitable",
"explicit-override",
]
warn_unreachable = true

[tool.ruff]
# See https://github.com/charliermarsh/ruff#rules for error code definitions.
select = [
Expand Down
29 changes: 16 additions & 13 deletions zulint/lister.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,22 @@ def list_files(
):
continue

if ftypes or group_by_ftype:
try:
filetype = get_ftype(fpath, use_shebang)
except (OSError, UnicodeDecodeError) as e:
etype = e.__class__.__name__
print(
f'Error: {etype} while determining type of file "{fpath}":',
file=sys.stderr,
)
print(e, file=sys.stderr)
filetype = ""
if ftypes and filetype not in ftypes_set:
continue
if not ftypes and not group_by_ftype:
result_list.append(fpath)
continue

try:
filetype = get_ftype(fpath, use_shebang)
except (OSError, UnicodeDecodeError) as e:
etype = e.__class__.__name__
print(
f'Error: {etype} while determining type of file "{fpath}":',
file=sys.stderr,
)
print(e, file=sys.stderr)
filetype = ""
if ftypes and filetype not in ftypes_set:
continue

if group_by_ftype:
result_dict[filetype].append(fpath)
Expand Down

0 comments on commit 0d68c1f

Please sign in to comment.