You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In case an opener is used into open() function, for creating a file with certain permission for instance, ruff PTH123 suggests to use pathlib.Path.open() which does not implement the opener.
importosdir_fd=os.open('somedir', os.O_RDONLY)
defopener(path, flags):
returnos.open(path, flags, dir_fd=dir_fd)
withopen('spamspam.txt', 'w', opener=opener) asf:
print('This will be written to somedir/spamspam.txt', file=f)
…tter doesn't support all options
**Summary** Check that `closefd` and `opener` aren't being used with `builtin.open()` before suggesting `Path.open()` because pathlib doesn't support these arguments.
Closes#7620
**Test Plan** New cases in the fixture
…tter doesn't support all options (#7637)
**Summary** Check that `closefd` and `opener` aren't being used with
`builtin.open()` before suggesting `Path.open()` because pathlib doesn't
support these arguments.
Closes#7620
**Test Plan** New cases in the fixture.
Issue
In case an
opener
is used intoopen()
function, for creating a file with certain permission for instance, ruffPTH123
suggests to usepathlib.Path.open()
which does not implement theopener
.Reference
open()
pathlib.Path.open()
Solution
opener
is defined# noqa: PTH123
The text was updated successfully, but these errors were encountered: