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

Bug with match.group().count in loop on v1.15.0 #18738

Open
kmurphy4 opened this issue Feb 25, 2025 · 0 comments
Open

Bug with match.group().count in loop on v1.15.0 #18738

kmurphy4 opened this issue Feb 25, 2025 · 0 comments
Labels
bug mypy got something wrong

Comments

@kmurphy4
Copy link

Bug Report

On v1.15.0, with mypy --warn-unreachable ... successfully finds no errors with

import re
re.sub("x", lambda m: m.group().count("x") * "x", "x")

but reports an error with

import re
for _ in re.findall("x", "x"):
    re.sub("x", lambda m: m.group().count("x") * "x", "x")  # E: Argument 1 to "count" of "bytes" has incompatible type "str"; expected "Buffer | SupportsIndex"  [arg-type]

for reference, both examples pass with v1.14.1 and with v1.15.0 without --warn-unreachable.

@kmurphy4 kmurphy4 added the bug mypy got something wrong label Feb 25, 2025
@kmurphy4 kmurphy4 changed the title Crash with match.group().count in loop on v1.15.0 Bug with match.group().count in loop on v1.15.0 Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant