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

[pylint] Do not report calls when object type and argument type mismatch, remove custom escape handling logic (PLE1310) #15984

Merged
merged 4 commits into from
Feb 7, 2025

Conversation

InSyncWithFoo
Copy link
Contributor

@InSyncWithFoo InSyncWithFoo commented Feb 6, 2025

Summary

Resolves #15968.

Previously, these would be considered violations:

b''.strip('//')
''.lstrip('//', foo = "bar")

...while these are not:

b''.strip(b'//')
''.strip('\\b\\x08')

Ruff will now not report when the types of the object and that of the argument mismatch, or when there are extra arguments.

Test Plan

cargo nextest run and cargo insta test.

Copy link
Contributor

github-actions bot commented Feb 6, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Collaborator

@dylwil3 dylwil3 left a comment

Choose a reason for hiding this comment

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

Looks good! Function doc comment needs an update, and I'm confused about why we changed the behavior for Python versions below 3.9.

@MichaReiser MichaReiser added bug Something isn't working rule Implementing or modifying a lint rule labels Feb 6, 2025
Copy link
Collaborator

@dylwil3 dylwil3 left a comment

Choose a reason for hiding this comment

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

Thank you!

@dylwil3 dylwil3 merged commit 19f3424 into astral-sh:main Feb 7, 2025
21 checks passed
@InSyncWithFoo InSyncWithFoo deleted the PLE1310 branch February 7, 2025 20:34
MichaReiser pushed a commit that referenced this pull request Feb 10, 2025
…15985)

## Summary

Follow-up to #15984.

Previously, `PLE1310` would only report when the object is a literal:

```python
'a'.strip('//')  # error

foo = ''
foo.strip('//')  # no error
```

After this change, objects whose type can be inferred to be either `str`
or `bytes` will also be reported in preview.

## Test Plan

`cargo nextest run` and `cargo insta test`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PLE1310 fails on bytes.strip
3 participants