Skip to content

B901: Misses yield sub-expresisons #14453

@MichaReiser

Description

@MichaReiser

A very contrived example but B901 misses yield expressions where they're not the expression of a ExprStmt.

def get_file_paths(file_types: Iterable[str] | None = None) -> Iterable[Path]:
    dir_path = Path(".")
    if file_types is None:
        return dir_path.glob("*")

    for file_type in file_types:
        (yield a for a in dir_path.glob(f"*.{file_type}"))

Note: we should make sure that we don't traverse into any lambda expressions...

Metadata

Metadata

Assignees

Labels

needs-designNeeds further design before implementationruleImplementing or modifying a lint rule

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions