Skip to content

Conversation

@marc-hb
Copy link
Collaborator

@marc-hb marc-hb commented Nov 4, 2025

As kindly suggested by the existing "types" target:

$ uv run poe types

Poe => mypy --package west

src/west/app/project.py:1364: note: By default the bodies of untyped
functions are not checked, consider using --check-untyped-defs
[annotation-unchecked]

Do not include in the "all" group because it's not passing.

As kindly suggested by the existing "types" target:

$ uv run poe types

Poe => mypy --package west

src/west/app/project.py:1364: note: By default the bodies of untyped
functions are not checked, consider using --check-untyped-defs
[annotation-unchecked]

Do not include in the "all" group because it's not passing.

Signed-off-by: Marc Herbert <[email protected]>
This was the only --check-untyped-defs warning in manifest.py: easy win.

Signed-off-by: Marc Herbert <[email protected]>
@marc-hb marc-hb marked this pull request as ready for review November 4, 2025 01:13
def get(self, option, **kwargs):
def get(
self, option: str, default: str | None = None, configfile: ConfigFile = ConfigFile.ALL
) -> str | None:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a public, documented method so it's not going to change any time soon.

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.40%. Comparing base (a4ce10a) to head (205e522).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #875   +/-   ##
=======================================
  Coverage   84.40%   84.40%           
=======================================
  Files          11       11           
  Lines        3385     3385           
=======================================
  Hits         2857     2857           
  Misses        528      528           
Files with missing lines Coverage Δ
src/west/manifest.py 95.33% <100.00%> (ø)

@marc-hb
Copy link
Collaborator Author

marc-hb commented Nov 4, 2025

Current output

$ uv run poe types-extra

Poe => mypy --package west --check-untyped-defs

src/west/commands.py:731: error: Invalid index type "Path" for "dict[str, Module]"; expected type "str"  [index]
src/west/commands.py:735: error: Argument 1 to "module_from_spec" has incompatible type "ModuleSpec | None"; expected "ModuleSpec"  [arg-type]
src/west/commands.py:736: error: Item "None" of "ModuleSpec | None" has no attribute "loader"  [union-attr]
src/west/commands.py:736: error: Item "None" of "Loader | Any | None" has no attribute "exec_module"  [union-attr]

src/west/app/project.py:584: error: Argument 1 to "join" has incompatible type "str | None"; expected "str"  [arg-type]
src/west/app/project.py:787: error: Argument 1 to "Path" has incompatible type "str | None"; expected "str | PathLike[str]"  [arg-type]
src/west/app/project.py:791: error: Argument 1 to "Path" has incompatible type "str | None"; expected "str | PathLike[str]"  [arg-type]
src/west/app/project.py:1364: error: "List" expects no type arguments, but 1 given  [type-arg]
src/west/app/project.py:1364: error: Incompatible types in assignment (expression has type "list[Never]", variable has type "west.app.project.List")  [assignment]
src/west/app/project.py:1374: error: "west.app.project.List" has no attribute "append"  [attr-defined]
src/west/app/project.py:1395: error: Need type annotation for "updated" (hint: "updated: set[<type>] = ...")  [var-annotated]
src/west/app/project.py:1595: error: Need type annotation for "stats" (hint: "stats: dict[<type>, <type>] = ...")  [var-annotated]
src/west/app/project.py:1642: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
src/west/app/project.py:1642: error: Unsupported operand types for - (likely involving Union)  [operator]
src/west/app/project.py:1650: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
src/west/app/project.py:1658: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
src/west/app/project.py:1666: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
src/west/app/project.py:1671: error: Item "None" of "dict[Any, Any] | None" has no attribute "values"  [union-attr]
src/west/app/project.py:1672: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
src/west/app/project.py:1673: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
src/west/app/project.py:1675: error: Item "None" of "dict[Any, Any] | None" has no attribute "items"  [union-attr]
src/west/app/project.py:2416: error: Argument 1 to "PurePath" has incompatible type "str | None"; expected "str | PathLike[str]"  [arg-type]

src/west/app/main.py:227: error: "object" has no attribute "__iter__"; maybe "__dir__" or "__str__"? (not iterable)  [attr-defined]
src/west/app/main.py:371: error: Item "None" of "Any | None" has no attribute "args"  [union-attr]
src/west/app/main.py:392: error: Item "None" of "Any | None" has no attribute "filename"  [union-attr]
src/west/app/main.py:394: error: Unsupported left operand type for + ("None")  [operator]
src/west/app/main.py:394: note: Left operand is of type "Any | None"
src/west/app/main.py:400: error: Item "None" of "Any | None" has no attribute "filename"  [union-attr]
src/west/app/main.py:415: error: Incompatible types in assignment (expression has type "None", variable has type "dict[Any, Any]")  [assignment]
src/west/app/main.py:419: error: Argument 1 to "extension_commands" has incompatible type "Any | None"; expected "Configuration"  [arg-type]
src/west/app/main.py:479: error: Item "None" of "Any | None" has no attribute "err"  [union-attr]
src/west/app/main.py:611: error: Item "None" of "Any | None" has no attribute "parse_known_args"  [union-attr]
src/west/app/main.py:670: error: Item "None" of "Any | None" has no attribute "err"  [union-attr]
src/west/app/main.py:673: error: Item "None" of "Any | None" has no attribute "verbosity"  [union-attr]
src/west/app/main.py:674: error: Item "None" of "Any | None" has no attribute "banner"  [union-attr]
src/west/app/main.py:689: error: Item "None" of "Any | None" has no attribute "die"  [union-attr]
src/west/app/main.py:691: error: Item "None" of "Any | None" has no attribute "die"  [union-attr]
src/west/app/main.py:721: error: Item "None" of "Any | None" has no attribute "print_usage"  [union-attr]
src/west/app/main.py:828: error: Item "None" of "Any | None" has no attribute "get"  [union-attr]
src/west/app/main.py:829: error: Item "None" of "Any | None" has no attribute "get"  [union-attr]
src/west/app/main.py:835: error: Item "None" of "Any | None" has no attribute "get_projects"  [union-attr]
src/west/app/main.py:838: error: Item "None" of "Any | None" has no attribute "get_projects"  [union-attr]
src/west/app/main.py:838: error: Argument 1 to "Path" has incompatible type "Any | None"; expected "str | PathLike[str]"  [arg-type]
src/west/app/main.py:843: error: Item "None" of "Any | None" has no attribute "set"  [union-attr]
src/west/app/main.py:846: error: Argument 1 to "Path" has incompatible type "Any | None"; expected "str | PathLike[str]"  [arg-type]
src/west/app/main.py:935: error: "Help" has no attribute "app"  [attr-defined]
src/west/app/main.py:936: error: "Help" has no attribute "app"  [attr-defined]
src/west/app/main.py:1165: error: Need type annotation for "optional"  [var-annotated]
src/west/app/main.py:1170: error: Item "None" of "list[Any] | Any | None" has no attribute "append"  [union-attr]

Found 48 errors in 3 files (checked 12 source files)

cc: @thorsten-klein

@marc-hb
Copy link
Collaborator Author

marc-hb commented Nov 4, 2025

Then, maybe we could run this failing checkin in CI with a continue-on-error: true?

Similarly to 361004d? I forgot how that went.

Either way this can be merged first.

@thorsten-klein
Copy link
Contributor

thorsten-klein commented Nov 4, 2025

Why not enabling --check-untyped-defs and fixing all those findings so that it passes?
This also ensures that all new code is compliant.
I am afraid, for users it becomes more and more complex to know what checks must pass and which ones not and what runs in CI.

I will start fixing the issues on main👍

@pdgendt
Copy link
Collaborator

pdgendt commented Nov 4, 2025

I will start fixing the issues on main👍

I'd also like it if the issues were dealt with, and we can simply enable the untyped checks in the types task as a default.

@marc-hb
Copy link
Collaborator Author

marc-hb commented Nov 4, 2025

Why not enabling --check-untyped-defs and fixing all those findings so that it passes?
This also ensures that all new code is compliant.

  1. Because... it takes a lot of time?!? There are 50 of them. Some may be easy, others not at all. Some may require major and possibly pointless refactoring. You generally don't want to completely turn the code upside for a false positive warning. Warnings are not always correct, if they were then they would be errors.

More importantly, because:

  1. Some extra warnings may not be fixable at all. This is most likely the reason why --check-untyped-defs is not enabled by default, the same way gcc -Wextra has many warnings not included in gcc -Wall by default: because it's often impossible to fix "extra" warnings on codebases of moderate size.

I am afraid, for users it becomes more and more complex to know what checks must pass and which ones not and what runs in CI.

That's why this PR is not adding anything to CI. If you want the extra, unfixable warnings then it's now very easy to see them. If you don't, then just keep ignoring as you've been doing before. The same "extra" logic could apply to other options than --check-untyped-defs - even if all --check-untyped-defs turn out to be fixable.

BTW there are --check-untyped-defs warnings in only three files (the bigger and more complex ones), so it's easy to spot warnings in other files. That's one value of types-extra.

@marc-hb
Copy link
Collaborator Author

marc-hb commented Nov 4, 2025

I will start fixing the issues on main👍

Great but please avoid git conflicts with PRs currently in progress (unless it's an actual bug and not just a warning).

EDIT, see:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants