|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -import builtins |
16 | | -import itertools |
17 | | -import keyword |
18 | | - |
| 15 | +# DO NOT CHANGE this file, except when you need to add a new reserved keyword |
| 16 | +# from Python's new major release. |
| 17 | +# In an unforseen case if you have to make changes, please follow the process: |
| 18 | +# 1. Run the internal script to check if any of the existing Google APIs use the |
| 19 | +# item to be added/removed. For external contributors, ask a Googler to do that |
| 20 | +# during code review. |
| 21 | +# 2. If no APIs are using it, it's safe to add. Otherwise, consult with your TL. |
| 22 | +# |
| 23 | +# Changing this list will lead to breaking changes. This is happening because |
| 24 | +# GAPIC will add "_" to field names from that list. This will change the generated |
| 25 | +# client library surface (i.e. breaking change). Example of when this happened: |
| 26 | +# https://github.com/googleapis/gapic-generator-python/issues/835. |
19 | 27 |
|
20 | | -# The exceptions to builtins are frequent and useful. |
21 | | -# They are explicitly allowed message, module, and field names. |
| 28 | +# Each item in the list belongs to one of the following categories: |
| 29 | +# 1. Python keyword |
| 30 | +# 2. Used in Google APIs at the time of writing this PR |
| 31 | +# 3. Reserved word from Protoplus. |
22 | 32 | RESERVED_NAMES = frozenset( |
23 | | - itertools.chain( |
24 | | - # We CANNOT make exceptions for keywords. |
25 | | - keyword.kwlist, |
26 | | - # We make SOME exceptions for certain names that collide with builtins. |
27 | | - set(dir(builtins)) - {"filter", "map", "id", |
28 | | - "input", "property", "vars", "set"}, |
29 | | - # "mapping" and "ignore_unknown_fields" have special uses |
30 | | - # in the constructor of proto.Message |
31 | | - {"mapping", "ignore_unknown_fields"}, |
32 | | - ) |
| 33 | + [ |
| 34 | + "any", |
| 35 | + "format", |
| 36 | + "yield", |
| 37 | + "await", |
| 38 | + "False", |
| 39 | + "return", |
| 40 | + "continue", |
| 41 | + "as", |
| 42 | + "pass", |
| 43 | + "next", |
| 44 | + "class", |
| 45 | + "list", |
| 46 | + "breakpoint", |
| 47 | + "import", |
| 48 | + "mapping", |
| 49 | + "zip", |
| 50 | + "locals", |
| 51 | + "max", |
| 52 | + "and", |
| 53 | + "finally", |
| 54 | + "dir", |
| 55 | + "def", |
| 56 | + "elif", |
| 57 | + "from", |
| 58 | + "nonlocal", |
| 59 | + "min", |
| 60 | + "not", |
| 61 | + "object", |
| 62 | + "global", |
| 63 | + "with", |
| 64 | + "else", |
| 65 | + "__peg_parser__", |
| 66 | + "del", |
| 67 | + "range", |
| 68 | + "open", |
| 69 | + "assert", |
| 70 | + "all", |
| 71 | + "except", |
| 72 | + "while", |
| 73 | + "license", |
| 74 | + "raise", |
| 75 | + "True", |
| 76 | + "lambda", |
| 77 | + "for", |
| 78 | + "or", |
| 79 | + "if", |
| 80 | + "in", |
| 81 | + "async", |
| 82 | + "slice", |
| 83 | + "is", |
| 84 | + "break", |
| 85 | + "hash", |
| 86 | + "None", |
| 87 | + "try", |
| 88 | + "type", |
| 89 | + # Comes from Protoplus |
| 90 | + "ignore_unknown_fields" |
| 91 | + ] |
33 | 92 | ) |
0 commit comments