Commit Graph

28 Commits

Author SHA1 Message Date
Anton Grübel
c38171a0b3 Use _typeshed.Self with __enter__ (#5712) 2021-06-29 15:19:25 -07:00
Charly C
389b92cb04 fix the stub files for the stdlib mmap module (#5705)
In Python 3:
- The `mmap` type is `Iterable[int]`, not `Iterable[bytes]`.
- The `read_byte` method returns an `int`, and the `write_byte` method only accepts an `int` as its first and only argument.
- The `__setitem__` method accepts any `ReadableBuffer` object, not just `bytes`.

In both Python 2 and 3:
- The `__delitem__` method always raises a `TypeError`, so the proper return type is `NoReturn`.
- The `mmap` type isn't generic, so I've simplified the stubs by removing the unnecessary `_mmap` class.
2021-06-29 08:01:32 -07:00
Thomas Grainger
2cd7e6511b fix abcmeta.ABCMeta type (#5688)
Add __abstractmethods__, __instancecheck__ and __subclasscheck__

Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-06-24 16:56:09 +03:00
Sebastian Rittau
816a92b8e8 Add Self type var to _typeshed (#5677)
Cf. #5676
2021-06-22 22:15:27 +02:00
layday
5a256a0c70 Fix sysconfig.get_path return type (#5659)
`get_path` uses key access and raises `KeyError` for missing keys.
2021-06-18 12:45:23 +02:00
Shantanu
04fb7ceb3c builtins: add a getattr overload for bool (#5518)
As brought up in https://github.com/python/typeshed/pull/5516

Alternatives include:
- Use another type var that has a value restriction
- Doing something fancy with Protocols that have a __bool__ that returns
  a Literal (which may not work)
- Doing nothing
2021-05-29 07:09:38 -07:00
scaramallion
af33b09bf6 Use __new__ for datetime.timedelta (#5532) 2021-05-26 11:05:26 +02:00
scaramallion
a32d24cae0 Use __new__ for datetime.time (#5530) 2021-05-26 11:00:37 +03:00
Neil Vyas
8d56328a24 change getattr stubs to better type the default argument and return type (#5516)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-05-21 16:44:11 -07:00
Jukka Lehtosalo
e5459900c0 Make html, ipaddress, reprlib and winreg only available on Python 3 (#5502)
None of these are available in Python 2.7.
2021-05-19 12:16:10 +01:00
Jukka Lehtosalo
b08a2e6dea Fix Python 2 genericpath.commonprefix (#5500)
The more specific overload item should come first. Also
fix the return type.
2021-05-19 12:56:18 +02:00
Sebastian Rittau
f0bf6eebbd AnyStr cleanup (#5487)
* Replace all uses of StrPath, BytesPath, and AnyPath in Python 2 stubs.
* Add StrOrBytesPath as preferred alias for AnyPath.
* Replace all remaining AnyPath instances with StrOrBytesPath.
* Mark AnyPath as obsolete.

Part of #5470
2021-05-17 20:45:48 +02:00
Sebastian Rittau
7a9a107a63 Move IdentityFunction to _typeshed (#5483)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2021-05-17 12:04:35 +02:00
Akuli
17dcea4a68 Akuli and srittau: Remove Python 2 branches from Python 3 stubs (#5461)
* run script and do some manual changes (Akuli)

* do the whole thing manually (srittau)

* merge changes (Akuli)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2021-05-15 15:33:39 +03:00
Akuli
15b0959cf8 stdlib/@python2: clean imports (#5453) 2021-05-15 01:08:37 +02:00
Akuli
5ec4f06263 clean python 3 specific stuff from stdlib/@python2 stubs (#5451) 2021-05-15 00:19:05 +02:00
Jelle Zijlstra
a47ee3245a fix renamed Python 2 modules (#5450) 2021-05-14 14:36:00 -07:00
Sebastian Rittau
5b739e0ccb Split stdlib into Python 2 and 3 versions (#5442)
All new files in stdlib/@python2 are straight copies of the
corresponding files in stdlib.
2021-05-14 12:04:12 -07:00
Shantanu
a91c89ea94 various path stubs: re-export to reduce duplication (#5382)
Co-authored-by: hauntsaninja <>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-05-10 22:27:13 -07:00
Terence Honles
63696823d7 typing: type decorators so they don't count as untyped lines (#5348) 2021-05-06 15:57:52 -07:00
Eric Traut
58e083fef9 Marked the bool class as @final because it cannot be subclassed. (#5286)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-05-01 21:38:10 -07:00
Sebastian Rittau
4ac3ccad45 black: enable skip_magic_trailing_comma (#5252)
* black: enable skip_magic_trailing_comma

* Remove spurious commas
2021-04-27 08:32:32 -07:00
Sebastian Rittau
45916045c8 Upgrade black to 21.4b0 and reformat (#5250)
This introduces newlines before decorators.
2021-04-26 13:58:27 +02:00
Sebastian Rittau
bac1918b5f PathLike cleanup (#5242)
Copy builtins._PathLike to os.PathLike

Use os.PathLike exclusively outside of builtins
2021-04-23 10:15:07 -07:00
Sebastian Rittau
0cea325bc7 Modernize logging (#5068) 2021-03-22 19:26:43 -07:00
Sebastian Rittau
08b26b9e8e Split and restore correct Python 2 version of cgi.pyi (#5064)
* Split cgi.pyi into Py2 and 3 versions

* Restore correct Python 2 version of cgi.pyi

* Remove unnecessary version checks in cgi.pyi

* Use collections.abc

* Use List in Python 2 stub
2021-02-24 14:46:03 -08:00
Henry Schreiner
e4f239edfd plat_ver: add missing type annotations (#5017)
Matches Python 3, and the description here: https://docs.python.org/2.7/library/platform.html#mac-os-platform
2021-02-11 21:02:09 -08:00
Ivan Levkivskyi
16ae4c6120 Re-organize directory structure (#4971)
See discussion in #2491

Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
2021-01-27 12:00:39 +00:00