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

[red-knot] scope bug with nested for loops #13879

Open
alex opened this issue Oct 22, 2024 · 0 comments
Open

[red-knot] scope bug with nested for loops #13879

alex opened this issue Oct 22, 2024 · 0 comments
Labels
bug Something isn't working red-knot Multi-file analysis & type inference

Comments

@alex
Copy link
Contributor

alex commented Oct 22, 2024

(I'm aware that red-knot is not yet stable).

This was tested with 7dbd8f0f8e725d05cc1d15e6ef1c6cc2ed2b2090 with no Ruff settings.

Code:

import datetime


def get_weeks() -> list[datetime.date]:
    raise NotImplementedError


def get_week_groups() -> list[list[datetime.date]]:
    pass


def main():
    weeks = get_weeks()
    all_week_groups = get_week_groups()
    for week in weeks:
        for group in all_week_groups:
            if any(d == week for d in group):
                print("Blah")

red-knot output:

/t/ruff ❯❯❯ ./target/release/red_knot --current-directory=z/
ERROR /private/tmp/ruff/z/t.py:17:25: Name `week` used when possibly not defined

But obviously week is always defined there.

@AlexWaygood AlexWaygood added bug Something isn't working red-knot Multi-file analysis & type inference labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working red-knot Multi-file analysis & type inference
Projects
None yet
Development

No branches or pull requests

2 participants