Skip to content
Closed
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
5 changes: 3 additions & 2 deletions mesonbuild/utils/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class _VerPickleLoadable(Protocol):
# A generic type for pickle_load. This allows any type that has either a
# .version or a .environment to be passed.
_PL = T.TypeVar('_PL', bound=T.Union[_EnvPickleLoadable, _VerPickleLoadable])
FileTypes = T.TypeVar('FileTypes', 'File', str, T.Union['File', str])

FileOrString = T.Union['File', str]

Expand Down Expand Up @@ -472,8 +473,8 @@ def get_compiler_for_source(compilers: T.Iterable['Compiler'], src: 'FileOrStrin
raise MesonException(f'No specified compiler can handle file {src!s}')


def classify_unity_sources(compilers: T.Iterable['Compiler'], sources: T.Sequence['FileOrString']) -> T.Dict['Compiler', T.List['FileOrString']]:
compsrclist: T.Dict['Compiler', T.List['FileOrString']] = {}
def classify_unity_sources(compilers: T.Iterable[Compiler], sources: T.Iterable[FileTypes]) -> T.Dict[Compiler, T.List[FileTypes]]:
Copy link
Member

Choose a reason for hiding this comment

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

This patch is itself the thing I stated must be destroyed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

--verbose, you mean that str is T.Iterable[str] just like it is T.Sequence[str]? This approach is still preferrable to yours if changed to have T.List[FileTypes] as the argument:

Suggested change
def classify_unity_sources(compilers: T.Iterable[Compiler], sources: T.Iterable[FileTypes]) -> T.Dict[Compiler, T.List[FileTypes]]:
def classify_unity_sources(compilers: T.Iterable[Compiler], sources: T.List[FileTypes]) -> T.Dict[Compiler, T.List[FileTypes]]:

I just checked and it still passes run_mypy. I'm opening a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

I already have a PR. :P

The context is #15057 (comment)

Copy link
Collaborator

@bonzini bonzini Oct 3, 2025

Choose a reason for hiding this comment

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

I know but I disagree that Union is the right solution.

Ok, won't open a PR but you can pick it yourself at https://github.com/bonzini/meson/commit/8e072288ffa0bca7e3c338d6ec5ca4588e5e8e0d.patch

compsrclist: T.Dict['Compiler', T.List[FileTypes]] = {}
for src in sources:
comp = get_compiler_for_source(compilers, src)
if comp not in compsrclist:
Expand Down
Loading