Commit Graph

36 Commits

Author SHA1 Message Date
Alex Waygood
b63c963077 Use conditional overloads to simplify several stdlib functions (#7540) 2022-03-25 08:47:03 +01:00
Alex Waygood
3ab250eec8 Use PEP 604 syntax wherever possible (#7493) 2022-03-16 16:01:33 +01:00
Alex Waygood
f4ae363b56 stdlib: correct many pos-or-kw arg names in dunder methods (#7451) 2022-03-07 16:40:03 +01:00
Alex Waygood
4f0d8c593e Delete EnumMeta.__setattr__ and EnumMeta.__delattr__ (#7388) 2022-02-26 17:55:53 -08:00
Alex Waygood
2d6ab4d3bf Fix several mypy errors when run on the 3.11 stdlib (#7389) 2022-02-26 17:49:36 -08:00
Alex Waygood
1610949c66 Improve enum stubs (#7362)
- Improve TypeVar names
- `object` -> `Any` in `Enum.__new__` (there _are_ restrictions on the kinds of objects that can be passed in, they're just not expressable in the stubs.
- Delete pointless `Self | int` unions, since `Self` is a subtype of `int` for these methods.
2022-02-22 20:17:55 +01:00
Alex Waygood
a37d5f4849 Add enum module features new in 3.11 (#7358) 2022-02-22 08:42:03 -08:00
Alex Waygood
953f815f6b Add EnumMeta.__prepare__ (#7243) 2022-02-20 15:57:21 -08:00
Alex Waygood
2fe519c3a7 Add __all__ for modules beginning with 'e', 'f' and 'g' (#7325) 2022-02-20 15:08:14 -08:00
Alex Waygood
fbc279e3f5 stdlib: Add many missing dunder overrides (#7231) 2022-02-16 06:25:47 -08:00
Alex Waygood
5972da2e2d Add EnumMeta.__bool__ (#7206)
Most Python objects evaluate as falsey if they have length 0, but an enum class is truthy even if it has length 0.

Source code: 841c77d802/Lib/enum.py (L353)
2022-02-14 13:03:17 -08:00
Shantanu
b88a6f19cd Upgrade black version (#7089) 2022-01-30 16:27:06 -08:00
Akuli
b2375ddaeb Enable pyright for Python 3.11 (#6904) 2022-01-12 20:07:57 +01:00
Alex Waygood
96c9abb058 Always use _typeshed.Self, where applicable (#6880)
* Always use `_typeshed.Self`, where applicable

* Revert changes to `google-cloud-ndb` (ambiguous)

* Remove empty line added by script

* Revert changes to `stubs/python-dateutil/dateutil/relativedelta.pyi`

* Manually add a few more that the script missed

* Improve `filelock` annotation

Source code here: 79ec7b2826/src/filelock/_api.py (L207)

* Improve `opentracing/scope` annotation

Source code here: 3e1d357a34/opentracing/scope.py (L71)

* Improve `redis/client` stub

Source code here: 15f315a496/redis/client.py (L1217)

* Improve `redis/lock` annotation

Source code here: 15f315a496/redis/lock.py (L155)

* Improve `requests/models` annotation

Source code here: d718e75383/requests/models.py (L653)
2022-01-09 19:16:19 -08:00
Alex Waygood
4e046163b5 Delete many redundant method redefinitions (#6877) 2022-01-09 11:21:03 -08:00
Alex Waygood
a40d79a4e6 Use lowercase type everywhere (#6853) 2022-01-08 16:09:29 +01:00
Alex Waygood
8d5d2520ac Use PEP 585 syntax wherever possible (#6717) 2021-12-28 11:31:43 +01:00
Alex Waygood
a7c9788948 Improve stub for enum.property (#6648) 2021-12-21 21:11:07 -08:00
Alex Waygood
519d70097b Update enum.pyi (#6629) 2021-12-20 17:51:48 -08:00
Alex Waygood
f3026dc3ab Improve enum.StrEnum (#6580)
A `StrEnum` can only have strings as values.
2021-12-13 17:59:31 +01:00
Alex Waygood
cc054efa79 Make name and value read-only for Enums, part II (#6578) 2021-12-13 17:00:28 +01:00
Alex Waygood
0f2e87e42a Make name and value read-only for Enums (#6576) 2021-12-13 16:08:49 +01:00
Alex Waygood
c3cd88ba91 Add EnumMeta.__new__ & EnumMeta.__call__ (#6572) 2021-12-13 12:33:54 +01:00
Nikita Sobolev
b1f0271da6 Add EnumType to enum.pyi on Python 3.11 (#6568) 2021-12-11 19:13:32 +02:00
Akuli
a5bc1e037f Add mypy error codes to '# type: ignore' comments (#6379) 2021-11-26 07:07:56 +01:00
Jake Bailey
b9ea346c14 Use overrides for IntFlag dunder-r methods (#6114) 2021-10-04 18:00:36 -07:00
Bas van Beek
b9e1d7d522 Replace Mapping with types.MappingProxyType (#6013)
Mark `Signature.parameters` and `.return_annotation` as read-only properties
2021-09-09 09:58:53 +02:00
Anthony Sottile
f1e367851c Fix types of enum _member_names, etc. (#5986)
Move fields onto EnumMeta
2021-09-02 11:46:57 +02:00
Akuli
ce11072dbe Big diff: use lower-case list and dict (#5888) 2021-08-08 09:26:35 -07:00
Akuli
ee487304d7 Big diff: Use new "|" union syntax (#5872) 2021-08-08 11:05:21 +02:00
Sebastian Rittau
acc576659a Use Python 3.10 beta 4 instead of beta 1 in CI (#5839)
Quote all Python versions to make sure they are interpreted as strings,
not floats.
2021-08-02 07:30:32 -07:00
Maarten ter Huurne
0d9521970d Mark enum.Flag.name as Optional[str] (#5611)
* Mark enum.Flag.name as Optional[str]

* Annotate enum.Flag.value
2021-06-16 19:25:47 +03:00
Shantanu
4a45b1d1b4 enum: update for py310 (#5314)
I remember there are some subtleties around Enum.__new__, that might be
relevant to StrEnum, but I'm forgetting the details.

I wasn't sure how best to handle the new enum.property. I could also
re-export, or take a more literal interpretation.

Co-authored-by: hauntsaninja <>
2021-05-04 15:12:19 +03:00
Maxime Arthaud
3536e2a080 Type the constructor of IntEnum and IntFlag (#5217)
These should only accept integers or enum members.
2021-04-14 18:41:07 -07:00
Eric Traut
e2967a8bee Eliminated the use of "bare" TypeVars in stdlib stubs (#5041)
Eliminated the use of "bare" TypeVars (i.e. a TypeVar that appears only once) within generic methods. While not considered an error in PEP 484, these are a common source of bugs in code, and some type checkers (including pytype and pyright) flag them as errors.

Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-02-27 19:43:45 -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