@@ -141,7 +141,14 @@ class type(object):
141
141
self , name : str , bases : Tuple [type , ...], dict : dict [str , Any ], ** kwds : Any
142
142
) -> None : ...
143
143
@overload
144
- def __new__ (cls , o : object ) -> type : ...
144
+ def __new__ (cls , o : object ) -> type :
145
+ """Get the type of an object.
146
+
147
+ Example: ``type("hello, world)``
148
+
149
+ :return: The type of the object passed in.
150
+ """
151
+ ...
145
152
@overload
146
153
def __new__ (
147
154
cls : Type [_TT ],
@@ -171,15 +178,32 @@ class super(object):
171
178
def __init__ (self ) -> None : ...
172
179
173
180
class int :
181
+ """Get an integer from a number or a string.
182
+ """
174
183
@overload
175
184
def __new__ (
176
185
cls : Type [_T ],
177
186
x : str | bytes | SupportsInt | SupportsIndex | _SupportsTrunc = ...,
178
- ) -> _T : ...
187
+ ) -> _T :
188
+ """Get an integer from a number or a string.
189
+
190
+ Example: ``int("1.2")``
191
+
192
+ :return: Zero if no argument is provided, or an ``int`` from a number or string truncated toward zero.
193
+ """
194
+ ...
179
195
@overload
180
196
def __new__ (
181
197
cls : Type [_T ], x : str | bytes | bytearray , base : SupportsIndex
182
- ) -> _T : ...
198
+ ) -> _T :
199
+ """Get an integer from a number or a string.
200
+
201
+ Example: ``int("8.3", 2)``
202
+
203
+ :param base: (default=10) Allowed bases are 0 and 2–36.
204
+ :return: Zero if no argument is provided, or an ``int`` from a number or string truncated toward zero.
205
+ """
206
+ ...
183
207
def to_bytes (
184
208
self ,
185
209
length : SupportsIndex ,
@@ -251,7 +275,14 @@ class int:
251
275
class float :
252
276
def __new__ (
253
277
cls : Type [_T ], x : SupportsFloat | SupportsIndex | str | bytes | bytearray = ...
254
- ) -> _T : ...
278
+ ) -> _T :
279
+ """Convert a string or number to a floating point number, if possible.
280
+
281
+ Example: ``float("1.2")``
282
+
283
+ :return: ``0.0`` if no argument is provided, or a ``float`` from a number or string.
284
+ """
285
+ ...
255
286
def __add__ (self , x : float ) -> float : ...
256
287
def __sub__ (self , x : float ) -> float : ...
257
288
def __mul__ (self , x : float ) -> float : ...
@@ -326,11 +357,29 @@ class complex:
326
357
327
358
class str (Sequence [str ]):
328
359
@overload
329
- def __new__ (cls : Type [_T ], o : object = ...) -> _T : ...
360
+ def __new__ (cls : Type [_T ], object : object = "" ) -> _T :
361
+ """Get a string version of an object.
362
+
363
+ Example: ``print("The number " + str(42) " is great!")``
364
+
365
+ :param object: (default="") Object to return a string version of.
366
+ :return: A string reprentation of an object.
367
+ """
368
+ ...
330
369
@overload
331
370
def __new__ (
332
- cls : Type [_T ], o : bytes , encoding : str = ..., errors : str = ...
333
- ) -> _T : ...
371
+ cls : Type [_T ], object : bytes = b"" , encoding : str = "uft-8" , errors : str = "strict"
372
+ ) -> _T :
373
+ """Get a string version of an object.
374
+
375
+ Example: ``print("The number " + str(42) " is great!")``
376
+
377
+ :param object: (default=b"") Object to return a string version of as bytes or a bytearray.
378
+ :param encoding: (default="uft-8") Encoding used to decode object.
379
+ :param errors: (default="strict") Something about error handling...
380
+ :return: A string reprentation of an object.
381
+ """
382
+ ...
334
383
def count (
335
384
self ,
336
385
x : str ,
@@ -813,11 +862,29 @@ class range(Sequence[int]):
813
862
stop : int
814
863
step : int
815
864
@overload
816
- def __init__ (self , stop : SupportsIndex ) -> None : ...
865
+ def __init__ (self , stop : SupportsIndex ) -> None :
866
+ """Get a range of values from 0 up tp the stop parameter.
867
+
868
+ Example: ``rangeTimesTwo = [x * 2 for x in range(5)]``
869
+
870
+ :param stop: An integer to determine the end of the range (exclusive).
871
+ :return: A range object
872
+ """
873
+ ...
817
874
@overload
818
875
def __init__ (
819
876
self , start : SupportsIndex , stop : SupportsIndex , step : SupportsIndex = ...
820
- ) -> None : ...
877
+ ) -> None :
878
+ """Get a range of values from 0 up tp the stop parameter.
879
+
880
+ Example: ``rangeTimesTwo = [x * 2 for x in range(1, 11, 2)]``
881
+
882
+ :param start: (default=0) An integer to determine the start of the range (inclusive).
883
+ :param stop: An integer to determine the end of the range (exclusive).
884
+ :param step: (default=1) The increment for each value in the range.
885
+ :return: A range object
886
+ """
887
+ ...
821
888
def __len__ (self ) -> int : ...
822
889
def __contains__ (self , o : object ) -> bool : ...
823
890
def __iter__ (self ) -> Iterator [int ]: ...
@@ -853,7 +920,15 @@ class _NotImplementedType(Any): # type: ignore
853
920
854
921
NotImplemented : _NotImplementedType
855
922
856
- def abs (__x : SupportsAbs [_T ]) -> _T : ...
923
+ def abs (__x : SupportsAbs [_T ]) -> _T :
924
+ """Get the absolute value of a number.
925
+
926
+ Example: ``abs(-42)``
927
+
928
+ :param __x: A number.
929
+ :return: The length of or number of items in an object.
930
+ """
931
+ ...
857
932
def all (__iterable : Iterable [object ]) -> bool : ...
858
933
def any (__iterable : Iterable [object ]) -> bool : ...
859
934
def bin (__number : int | SupportsIndex ) -> str : ...
@@ -862,7 +937,15 @@ if sys.version_info >= (3, 7):
862
937
def breakpoint (* args : Any , ** kws : Any ) -> None : ...
863
938
864
939
def callable (__obj : object ) -> bool : ...
865
- def chr (__i : int ) -> str : ...
940
+ def chr (__i : int ) -> str :
941
+ """Get a Unicode string representation of an integer.
942
+
943
+ Example: ``chr(97)``
944
+
945
+ :param __i: An integer within the range 0..1,114,111.
946
+ :return: A Unicode string representation of a number within a valid range.
947
+ """
948
+ ...
866
949
867
950
# We define this here instead of using os.PathLike to avoid import cycle issues.
868
951
# See https://github.com/python/typeshed/pull/991#issuecomment-288160993
@@ -919,10 +1002,30 @@ def getattr(__o: object, name: str, __default: _T) -> Any | _T: ...
919
1002
def globals () -> dict [str , Any ]: ...
920
1003
def hasattr (__obj : object , __name : str ) -> bool : ...
921
1004
def hash (__obj : object ) -> int : ...
922
- def help (* args : Any , ** kwds : Any ) -> None : ...
923
- def hex (__number : int | SupportsIndex ) -> str : ...
1005
+ def help (request : object ) -> None :
1006
+ """Starts interactive help or provides help for the request object, if valid.
1007
+
1008
+ Example: ``help("print")``
1009
+ """
1010
+ ...
1011
+ def hex (__number : int | SupportsIndex ) -> str :
1012
+ """Get the hexadecimal representation of an integer.
1013
+
1014
+ Example: ``hex(42)``
1015
+
1016
+ :return: The hexadecimal representation of an integer as a string.
1017
+ """
1018
+ ...
924
1019
def id (__obj : object ) -> int : ...
925
- def input (__prompt : Any = ...) -> str : ...
1020
+ def input (prompt : object = "" ) -> str :
1021
+ """Get user input as a string.
1022
+
1023
+ Example: ``prompt("Enter your name: ")``
1024
+
1025
+ :param prompt: (default="") Text prompt seen by users.
1026
+ :return: The length of or number of items in an object.
1027
+ """
1028
+ ...
926
1029
@overload
927
1030
def iter (__iterable : Iterable [_T ]) -> Iterator [_T ]: ...
928
1031
@overload
@@ -952,7 +1055,15 @@ else:
952
1055
__cls : type , __class_or_tuple : type | Tuple [type | Tuple [Any , ...], ...]
953
1056
) -> bool : ...
954
1057
955
- def len (__obj : Sized ) -> int : ...
1058
+ def len (__obj : Sized ) -> int :
1059
+ """Get the length of, or number of items in an object.
1060
+
1061
+ Example: ``len("Hello, world")``
1062
+
1063
+ :param __obj: A sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set).
1064
+ :return: The length of or number of items in an object.
1065
+ """
1066
+ ...
956
1067
def locals () -> dict [str , Any ]: ...
957
1068
958
1069
class map (Iterator [_S ], Generic [_S ]):
@@ -1104,14 +1215,33 @@ def open(
1104
1215
closefd : bool = ...,
1105
1216
opener : _Opener | None = ...,
1106
1217
) -> IO [Any ]: ...
1107
- def ord (__c : str | bytes ) -> int : ...
1218
+ def ord (__c : str | bytes ) -> int :
1219
+ """Get an integer representation of a Unicode character.
1220
+
1221
+ Example: ``ord("a")``
1222
+
1223
+ :param __c: A Unicode character.
1224
+ :return: The length of or number of items in an object.
1225
+ """
1226
+ ...
1108
1227
def print (
1109
1228
* values : object ,
1110
- sep : str | None = ...,
1111
- end : str | None = ...,
1112
- file : SupportsWrite [str ] | None = ...,
1113
- flush : bool = ...,
1114
- ) -> None : ...
1229
+ sep : str | None = " " ,
1230
+ end : str | None = "\n " ,
1231
+ file : SupportsWrite [str ] | None = None ,
1232
+ flush : bool = False ,
1233
+ ) -> None :
1234
+ """Prints values to a stream or standard output, typically the serial console.
1235
+
1236
+ Example: ``print("Hello, world")``
1237
+
1238
+ :param *values: Arguments or literals to print.
1239
+ :param sep: (default=" ") A string separator inserted between values.
1240
+ :param end: (default="\n ") A string appended after the last value.
1241
+ :param file: (default=None) A file-like object (stream).
1242
+ :param flush: (default=False) Whether to forcibly flush the stream.
1243
+ """
1244
+ ...
1115
1245
1116
1246
_E = TypeVar ("_E" , contravariant = True )
1117
1247
_M = TypeVar ("_M" , contravariant = True )
@@ -1160,11 +1290,37 @@ class reversed(Iterator[_T], Generic[_T]):
1160
1290
1161
1291
def repr (__obj : object ) -> str : ...
1162
1292
@overload
1163
- def round (number : SupportsRound [Any ]) -> int : ...
1293
+ def round (number : SupportsRound [Any ]) -> int :
1294
+ """Round a number to the nearest integer.
1295
+
1296
+ Example: ``round(42.42)``
1297
+
1298
+ :param number: A number to round to the nearest integer.
1299
+ :return: Round a number to the nearest integer.
1300
+ """
1301
+ ...
1164
1302
@overload
1165
- def round (number : SupportsRound [Any ], ndigits : None ) -> int : ...
1303
+ def round (number : SupportsRound [Any ], ndigits : None ) -> int :
1304
+ """Round a number to the nearest integer.
1305
+
1306
+ Example: ``round(42.42, None)``
1307
+
1308
+ :param number: A number to round to the nearest integer.
1309
+ :param ndigits: The number of decimal digits to round to.
1310
+ :return: Round a number to the nearest integer.
1311
+ """
1312
+ ...
1166
1313
@overload
1167
- def round (number : SupportsRound [_T ], ndigits : SupportsIndex ) -> _T : ...
1314
+ def round (number : SupportsRound [_T ], ndigits : SupportsIndex ) -> _T :
1315
+ """Round a number to the nearest integer.
1316
+
1317
+ Example: ``round(42.42, 1)``
1318
+
1319
+ :param number: A number to round to the number of decimal digits specified.
1320
+ :param ndigits: The number of decimal digits to round to.
1321
+ :return: The input number rounded to the number of decimal digits specified.
1322
+ """
1323
+ ...
1168
1324
def setattr (__obj : object , __name : str , __value : Any ) -> None : ...
1169
1325
@overload
1170
1326
def sorted (
0 commit comments