Skip to content

[flake8-use-pathlib] Fix PTH123 false positive when open is passed a file descriptor from a function call #17705

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

Merged
merged 3 commits into from
Apr 29, 2025

Conversation

LaBatata101
Copy link
Contributor

Summary

Includes minor changes to the semantic type inference to help detect the return type of function call.

Fixes #17691

Test Plan

Snapshot tests

…sed a file descriptor from a function call
Copy link
Contributor

github-actions bot commented Apr 29, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@LaBatata101
Copy link
Contributor Author

Why the CI failed here?

@AlexWaygood
Copy link
Member

Why the CI failed here?

I re-ran it and it passed. I assume it's just a fluke :-)

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thanks, this looks great to me! Let's just add a few test cases for bytestrings, but otherwise this is good to go.

@ntBre ntBre added bug Something isn't working rule Implementing or modifying a lint rule labels Apr 29, 2025
@ntBre ntBre merged commit 8c68d30 into astral-sh:main Apr 29, 2025
33 checks passed
dcreager added a commit that referenced this pull request Apr 30, 2025
* main:
  [red-knot] Use 'full' salsa backtrace output that includes durability and revisions (#17735)
  [red-knot] Initial support for protocol types (#17682)
  [red-knot] Computing a type ordering for two non-normalized types is meaningless (#17734)
  [red-knot] Include salsa backtrace in check and mdtest panic messages (#17732)
  [red-knot] Fix control flow for `assert` statements (#17702)
  [red-knot] Fix recording of negative visibility constraints (#17731)
  [red-knot] Update salsa (#17730)
  [red-knot] Support overloads for callable equivalence (#17698)
  [red-knot] Run py-fuzzer in CI to check for new panics (#17719)
  Upload red-knot binaries in CI on completion of linux tests (#17720)
  [`flake8-use-pathlib`] Fix `PTH123` false positive when `open` is passed a file descriptor from a function call (#17705)
@LaBatata101 LaBatata101 deleted the fix-PTH123 branch April 30, 2025 20:55
ntBre added a commit that referenced this pull request May 1, 2025
…ssed a file descriptor (#17712)

## Summary
Contains the same changes to the semantic type inference as
#17705.

Fixes #17694
<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

<!-- How was it tested? -->
Snapshot tests.

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
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.

PTH123 wrongly suggests Path.open() for file descriptors, only sometimes
3 participants