Commit Graph

51 Commits

Author SHA1 Message Date
kasium
f9cd5ee859 Improve ast types; revert several "redundant numeric union" changes from #7906 (#9130)
* Adapt number types in ast

Since mypy  0.990 type promotions was limited.
This means that complex is not longer promoted to int/float, therefore
we should adapt the types to list all possible types

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2022-11-14 09:41:23 +00:00
Nikita Sobolev
62a6c3d616 Annotate known magic-method return types (#9131) 2022-11-08 18:28:42 +00:00
Brendan Graham
f4ef058169 google.protobuf: Add an __init__ stub to fix type checking (#8982) 2022-10-25 13:20:43 -07:00
Nipunn Koorapati
f43ee406f1 Bump mypy-protobuf to 3.4.0 (#8951) 2022-10-21 01:26:57 +01:00
Nipunn Koorapati
bcad078264 types-protobuf: Bump the rev of protobuf supported to 4.21.8 (#8937) 2022-10-20 23:23:53 +01:00
Alex Waygood
97c935a3fe Fix protobuf stubtest errors (#8758) 2022-09-18 17:47:36 -07:00
Alex Waygood
246f7e7720 protobuf: fix stubtest errors (#8735) 2022-09-14 21:45:29 -07:00
Alexander Reynolds
fdbf1396d1 [protobuf] MessageToJson indent parameter can be None (#8705) 2022-09-08 13:41:18 +02:00
Nipunn Koorapati
7beaebff40 Bump to mypy-protobuf 3.3.0 (#8612)
* Bump to mypy-protobuf 3.3.0

* Remove some ignores for formatting
2022-08-26 07:24:11 +01:00
Nipunn Koorapati
c17c0d5607 Bump protobuf to 3.20.1 (#8609)
There are even newer versions available (4.*), but I had found a bug
in it which prevented it from working with mypy-protobuf. For now,
sticking to just 3.20.1
2022-08-25 13:28:08 +01:00
Alex Waygood
43f923b6c2 protobuf: Delete some __new__ and __init__ methods (#8088) 2022-06-16 17:10:14 +02:00
Alex Waygood
76a4bd796b Simplify and correct many numeric unions (#7906)
Unblocks PyCQA/flake8-pyi#222
2022-05-21 15:25:00 +01:00
Alex Waygood
fed1f35c32 Remove explicit inheritance from object (#7819) 2022-05-10 16:24:53 +03:00
Alex Waygood
ac30b96d14 Use str instead of Text (#7812) 2022-05-09 20:47:11 +01:00
Alex Waygood
b093c90a94 Use TypeAlias for type aliases where possible, part II (#7667) 2022-04-20 20:02:47 +01:00
Alex Waygood
653f2c6ba4 Third-party stubs: import from collections.abc where possible (#7637) 2022-04-16 14:52:57 +01:00
Alex Waygood
740193a8fc Use TypeAlias where possible for type aliases (#7630) 2022-04-15 18:01:00 -07:00
Jelle Zijlstra
fa9074366b Revert "Remove google/__init__.pyi (#6106)" (#7522)
This reverts commit a11a6643a7.
2022-03-21 19:49:00 +01:00
Nipunn Koorapati
a11a6643a7 Remove google/__init__.pyi (#6106)
Since google is a namespace package, it won't have an init.
Depends on https://github.com/typeshed-internal/stub_uploader/pull/33
2022-03-20 14:41:16 -07:00
Alex Waygood
e8286e7048 Use PEP 604 syntax in non-autogenerated protobuf stubs (#7506) 2022-03-17 11:34:31 +00:00
Nipunn Koorapati
96a09f6a35 protobuf: Bring back Message.Extensions (#7154) 2022-02-08 13:51:41 +01:00
Alex Waygood
494481a0ae Improve a bunch of __(deep)copy__ methods (#7148) 2022-02-06 15:40:44 -08:00
Aaron Sykes
ebcdcfa24e Makes DESCRIPTOR non nullable again (#7125)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-02-04 22:05:58 +02:00
Nipunn Koorapati
90f5422df7 Add/fix types to a bunch of non-generated protobuf files (#7017) 2022-02-02 12:30:39 +01:00
Nipunn Koorapati
470ea31ccd Use relax_strict_optional_primitives on protobuf generated code (#7038)
Per the suggestion in https://github.com/dropbox/mypy-protobuf/issues/344
This generates more permissive constructors (which protobuf itself actually
accepts).

Philosophically, I think it makes sense for the generated code hosted on
typeshed to be most permissive, while the generated code of individual
projects can make individual decisions (defaulting to less permissive).
2022-01-28 17:37:57 -08:00
Nipunn Koorapati
35064a7f75 Bump to mypy-protobuf 3.2.0 (#7013) 2022-01-23 14:49:33 -08:00
Alex Waygood
aea52b35d1 Remove nearly all __str__ and __repr__ methods from typeshed (#6968) 2022-01-20 00:45:11 +01:00
Alex Waygood
90d92aa0a5 Use _typeshed.Self in protobuf/google/protobuf/message.pyi (#6955) 2022-01-18 12:54:09 -08:00
Alex Waygood
8af5e0d340 Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where possible (#6949) 2022-01-18 07:14:03 -08:00
Nipunn Koorapati
fc4ba3ac64 Bump protobuf to 3.19.2 (#6879) 2022-01-10 10:03:41 +01:00
Nipunn Koorapati
b22f29bec1 Add google.protobuf.internal.api_implementation (#6802) 2022-01-03 22:00:19 +01:00
Alex Waygood
98af7d667f Improve stubs for sequence types (#6386) 2021-11-26 19:09:38 -08:00
Nipunn Koorapati
39867f1096 Bump protobuf stub to 3.18.1 and mypy-protobuf 3.0.0 (#6157)
* Bump protobuf stub to 3.18.1 and mypy-protobuf 3.0.0

* Fix ConsumeInteger in google/protobuf/text_format.pyi

The arg was removed in protobuf 3.18
2021-10-12 14:33:22 -07:00
Nipunn Koorapati
581b2d5180 Update protobuf generated stubs from mypy-protobuf 2.8 (#5804) 2021-07-23 16:21:26 -07:00
Nipunn Koorapati
6d6250f109 Supported repeated field containers for extensions (#5788)
See https://github.com/dropbox/mypy-protobuf/issues/244 for the
inspiration for this. Repeated extensions are allowed by protobuf,
and they generate to extension values with repeated fields.

Notably map fields (ScalarMap and MessageMap) are NOT allowed to be
extension values - producing errors as such - so those are omitted.

testproto/test_extensions3.proto:19:6: Map fields are not allowed to be extensions.
2021-07-16 10:11:42 -07:00
Nipunn Koorapati
5199ed5bd8 Upper bound protobuf containers based on scalar/composite (#5787) 2021-07-15 22:28:16 -07:00
Nipunn Koorapati
4765978f6c Support arbitrary values for extension values (#5774)
Proto itself supports primitives, not just messages.
See https://github.com/dropbox/mypy-protobuf/issues/244 for an example
motivating this change.

Test Plan: I was able to use MYPYPATH to test an updated version of
mypy-protobuf with this change.
2021-07-13 21:13:45 -07:00
Nipunn Koorapati
42eec29eed Update proto stubs with latest mypy-protobuf 2.6 (#5753) 2021-07-10 17:10:39 -07:00
Nipunn Koorapati
276c225cd9 Remove FieldDescriptor fallback for protobuf extension methods (#5754)
It was there for compatibility to older versions of mypy-protobuf.
With modular typeshed, this sort of straddling code will no longer
be necessary! Thanks @ilevkivskyi
2021-07-11 00:28:46 +02:00
Nipunn Koorapati
c5dd23ac0d Allow unicode and bytes in EnumTypeWrapper.Value (#5743) 2021-07-09 11:22:38 +02:00
Sebastian Rittau
711580722b Enable pyright for all Python 3 stubs (#5597)
* pyright: disable reportUnknownParameterType

Unknown parameter types are preferred over Any annotations for
incomplete stubs. Especially larger stubs are expected to be
incomplete for some time and it would be a shame to lose the
other pyright warnings for those stubs.

* Also disable reportUnknownVariableType

Fix problems with tkinter

* Disable reportUnknownMemberType

Fix pyright problems
2021-06-09 07:14:22 -07:00
Jukka Lehtosalo
a5e243fbcd Change some str types to Text in google.protobuf.text_format (#5343)
Python 2 `unicode` values are supported. For example:
https://github.com/protocolbuffers/protobuf/blob/master/python/google/protobuf/text_format.py#L843
2021-05-05 09:33:59 +01:00
Jukka Lehtosalo
fe4acabdd7 Allow bytes in addition to str in google.protobuf.text_format (#5267) 2021-04-30 15:46:29 +02: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
heroesm
2aff78dac2 Fix protobuf json_format signatures. (#5226) 2021-04-19 14:59:48 +02:00
Shantanu
fa9d5a5e9f future first: switch the order of some if statements (#5206)
Since we're adding this to our contribution guidelines in
https://github.com/python/typeshed/pull/5205
2021-04-11 06:44:18 -07:00
hatal175
5fef564636 Protobuf text_format stubs (#5167)
Fixes #1781
2021-04-08 18:02:38 -07:00
Dante Camarena
1d1d35c87a Updated descriptor.pyi in protobuf stubs. (#5007) 2021-02-22 15:15:44 +01:00
Alexander Reynolds
0b1cd59896 Updated protobuf descriptor pool (#5018) 2021-02-13 11:23:26 +01:00
Nipunn Koorapati
a3b3f6845b Allow unicode and bytes in the EnumTypeWrapper.Value classmethod (#5004)
Here is a unit test which shows that this behavior is accepted
by protobuf itself at runtime in both py2 and py3
https://github.com/dropbox/mypy-protobuf/pull/205
2021-02-04 15:03:37 +00:00