-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Reverted] Make os.stat_result and friends NamedTuples #1103
Conversation
stdlib/2/os/__init__.pyi
Outdated
('f_namemax', int)]) | ||
|
||
class stat_result(NamedTuple('stat_result', [ | ||
('st_mode', int), # protection bits, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need all of those comments. Typeshed is for types, not documentation.
stdlib/2/os/__init__.pyi
Outdated
# st_ctime. More items may be added at the end by some implementations. | ||
|
||
if sys.version_info >= (3, 3): | ||
st_atime_ns = 0 # time of most recent access, in nanoseconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to write st_atime_ns: int
(or st_atime_ns = ... # type: int
, but I think we've established that all users of typeshed obey PEP 526 now).
stdlib/3/os/__init__.pyi
Outdated
@@ -325,8 +321,11 @@ if sys.version_info >= (3, 5): | |||
def scandir(path: str = ...) -> Iterator[DirEntry[str]]: ... | |||
@overload | |||
def scandir(path: bytes) -> Iterator[DirEntry[bytes]]: ... | |||
@overload | |||
def stat_float_times(newvalue: bool = ...) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should have a default value; that will make it overlap with the other overload.
Thanks! Merged. |
Hmm... This caused two types of breakage with our internal code. I think it's better to roll back. @JelleZijlstra, @euresti What do you guys think? Here are the errors (same as I reported for #1111): This one's caused by the (newly introduced) difference between os.stat_result and posix.stat_result:
This one's triggered by
Who agrees with a rollback? |
We can fix the first one pretty easily by making stdlib/2/posix.pyi re-export os.stat_result (the one in stdlib/3 already does that). I don't think the second one can be fixed in the stubs, but maybe mypy is being too strict there (it could just allow that code and make it return Any). I'm OK with reverting for now, but it would be good to get some form of this PR back in eventually so |
I filed python/mypy#3078 for the latter. I'll revert if you don't beat me to it. |
This reverts commit 6c3e175.
Ack! Sorry about the mess. Please revert and I'll take a look later.
…On Mar 29, 2017 2:25 PM, "Guido van Rossum" ***@***.***> wrote:
I filed python/mypy#3078 <python/mypy#3078> for
the latter. I'll revert if you don't beat me to it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1103 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABCCArqkmnpXuGWPU2HwHDJRGq8GTrETks5rqqIlgaJpZM4MppiS>
.
|
The elements can be accessed as indexes or through attributes, so I chose to make them NamedTuples.