Skip to content

Commit 8facb82

Browse files
authored
Update PY3 cheat sheet with varargs example. (#3201)
1 parent 71c7b57 commit 8facb82

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/source/cheat_sheet.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ When you're puzzled or when things are complicated
134134
# type: (*str, **str) -> str
135135
request = make_request(*args, **kwargs)
136136
return self.do_api_query(request)
137-
138137
139138
# Use `ignore` to suppress type-checking on a given line, when your
140139
# code confuses mypy or runs into an outright bug in mypy.

docs/source/cheat_sheet_py3.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ When you're puzzled or when things are complicated
122122
# dynamic to write a type for.
123123
x = mystery_function() # type: Any
124124
125+
# This is how to deal with varargs.
126+
# This makes each positional arg and each keyword arg a 'str'.
127+
def call(self, *args: str, **kwargs: str) -> str:
128+
request = make_request(*args, **kwargs)
129+
return self.do_api_query(request)
130+
125131
# Use `ignore` to suppress type-checking on a given line, when your
126132
# code confuses mypy or runs into an outright bug in mypy.
127133
# Good practice is to comment every `ignore` with a bug link

0 commit comments

Comments
 (0)