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

False positive PD008 when using zipfile.Path.at #4466

Closed
m-roberts opened this issue May 17, 2023 · 1 comment · Fixed by #4474
Closed

False positive PD008 when using zipfile.Path.at #4466

m-roberts opened this issue May 17, 2023 · 1 comment · Fixed by #4474
Assignees
Labels
bug Something isn't working

Comments

@m-roberts
Copy link

ruff==0.0.267 has a false positive PD008:

import io
import zipfile


class MockBinaryFile(io.BytesIO):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def close(self):
        pass  # Don't allow closing the file, it would clear the buffer


zip_buffer = MockBinaryFile()

with zipfile.ZipFile(zip_buffer, "w") as zf:
    zf.writestr("dir/file.txt", "This is a test")

# Reset the BytesIO object's cursor to the start.
zip_buffer.seek(0)

with zipfile.ZipFile(zip_buffer, "r") as zf:
    zpath = zipfile.Path(zf, "/")

dir_name, file_name = zpath.at.split("/")
> ruff --select=PD008 a.py
a.py:24:23: PD008 Use `.loc` instead of `.at`.  If speed is important, use numpy.
   |
24 | dir_name, file_name = zpath.at.split("/")
   |                       ^^^^^^^^ PD008
   |

Found 1 error.
@charliermarsh charliermarsh added the bug Something isn't working label May 17, 2023
@charliermarsh
Copy link
Member

Thanks! Some of the PD false positives are hard to avoid, but this one should be fixable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants