[ty] Todo-types for os.fdopen, NamedTemporaryFile, and Path.open (#20549)

## Summary

This applies the trick that we use for `builtins.open` to similar
functions that have the same problem. The reason is that the problem
would otherwise become even more pronounced once we add understanding of
the implicit type of `self` parameters, because then something like
`(base_path / "test.bin").open("rb")` also leads to a wrong return type
and can result in false positives.

## Test Plan

New Markdown tests
This commit is contained in:
David Peter 2025-09-24 15:43:58 +02:00 committed by GitHub
parent eea87e24e3
commit fcc76bb7b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 240 additions and 100 deletions

View file

@ -318,6 +318,9 @@ pub enum KnownModule {
TypingExtensions,
Typing,
Sys,
Os,
Tempfile,
Pathlib,
Abc,
Dataclasses,
Collections,
@ -347,6 +350,9 @@ impl KnownModule {
Self::Typeshed => "_typeshed",
Self::TypingExtensions => "typing_extensions",
Self::Sys => "sys",
Self::Os => "os",
Self::Tempfile => "tempfile",
Self::Pathlib => "pathlib",
Self::Abc => "abc",
Self::Dataclasses => "dataclasses",
Self::Collections => "collections",