Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy: Enable strict mode and lots of errors #40

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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