Commit Graph

42 Commits

Author SHA1 Message Date
Eric Traut
c4d8507ff7 Removed unused import symbols from stdlib stubs and fixed a few other errors detected by pyright. I did a similar pass several months ago; these were introduced since then. (#4803)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2020-12-06 18:44:18 +01:00
Shantanu
6ff5b88ca7 typeshed: remove crufty comments (#4699)
Co-authored-by: hauntsaninja <>
2020-10-23 09:40:06 +02:00
Unrud
c5cc223313 Fix typo in constant name EAI_ADDRFAMILY (#4577) 2020-09-25 14:17:08 -07:00
Shantanu
c8c62b32ac socket: fix platform availability (#4507)
also fix another CI merge race issue

Co-authored-by: hauntsaninja <>
2020-08-31 14:20:46 -07:00
Shantanu
846e858bdc socket: add send_fds, recv_fds (#4501) 2020-08-31 22:03:30 +02:00
Eric Traut
bbd8c96e34 Added some missing types from various stdlib stubs (#4466) 2020-08-29 16:45:36 -07:00
Alex Grönholm
ad89dee03b Fixed return type of getaddrinfo() everywhere (#4304) 2020-07-10 10:46:28 +02:00
Alex Grönholm
f9d469ac2b Fixed parameter and return types of getnameinfo() everywhere (#4305) 2020-07-03 15:46:02 +02:00
Jelle Zijlstra
0142a87da8 adjust isort config (#4290)
Fixes #4288.

- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.

Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
2020-06-29 00:00:21 -07:00
Jelle Zijlstra
5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07:00
Jelle Zijlstra
44a852dff5 Literal: always import from typing_extensions for simplicity (#4219) 2020-06-10 21:23:58 -07:00
karl ding
2137026681 socket: Add missing CAN_BCM option flag constants (#4151)
The SocketCAN BCM option flag constants were added in version 3.9,
and only backported to version 3.8, despite the documentation's claims
of supporting all BCM-related constants starting from version 3.4.

Note: The CAN_FD_FRAME flag option was only introduced in the 4.8.x
kernel series, while the rest of the constants were available since the
Broadcast Manager was mainlined in the kernel as part of the SocketCAN
patches.
2020-06-01 01:21:54 +02:00
karl ding
09821cd9ca Add typing for CAN_J1939 sockets (#4141)
Add typing for CAN_J1939 sockets implementing support for the SAE J1939
protocol. This is available in Python 3.9+ on Linux 5.4+.
2020-05-29 12:33:47 +02:00
Brian Wellington
0bed1d3956 socket.create_connection source_address is optional. (#4133) 2020-05-28 19:56:11 +02:00
Rune Tynan
d51e13ad80 Add stubtest to Travis for windows (#4113) 2020-05-27 18:33:07 -07:00
Rune Tynan
f83e4aef7c Fix stubtest failures for socket on windows (#4102) 2020-05-27 09:38:45 +02:00
Shantanu
111f3f02ef socket: fix default mode for makefile (#3978)
Fixes #3977

Co-authored-by: hauntsaninja <>
2020-05-12 18:22:25 -07:00
tikki
bd55cae8b6 fix arg name to socket.getaddrinfo for py3 (#3689) 2020-01-30 18:45:38 -08:00
Jacob Ilias Komissar
eb6ce3cacb Fix socket.socket.ioctl (#3669)
Fixes #3495

Co-authored-by: Niels Buwen <nielsbuwen@users.noreply.github.com>
2020-01-27 21:25:33 -08:00
Jacob Ilias Komissar
39ebd62e71 Update stub for socket module (#3451)
* Add new socket constants from 3.7 and 3.8
* Also move TCP_NOTSENT_LOWAT to 3.7 section and add AF_ALG to AddressFamily
* Add missing and updated socket module (and class) methods
* Improve formatting of socket.pyi
    * Add missing line breaks in long function parameters
* Reorder to mirror module documentations
* Fix type of create_server's family parameter
* Add more system conditionals
* Remove CAPI; it isn't an int (it's a PyCapsule)
* Slightly improve version conditions in socket.pyi
* Add incomplete signatures for socket.sendfile and .sendmsg_afalg
* Add VM_SOCKETS_INVALID_VERSION to socket.pyi
* Remove private _GLOBAL_DEFAULT_TIMEOUT from socket.pyi
* Add mode-dependent return types to socket.makefile
    - For Python 2, return and mode types are based on those of 'open'
    - For Python 3, types are based on actual behaviors
* Mark recv_into and recvfrom_into's nbytes argument as optional
* Improve docstring for socket stub
2019-12-05 08:13:06 +01:00
Sebastian Rittau
0501e2b329 Annotations for remaining Python 3.8 additions (#3358)
* Add os.add_dll_directory()
* Add memfd_create() and flags
* Add type annotation to flags
* Add stat_result.st_reparse_tag and flags
* Add ncurses_version
* Add Path.link_to()
* Add Picker.reducer_override()
* Add plistlib.UID
* Add has_dualstack_ipv6() and create_server()
* Add shlex.join()
* Add SSL methods and fields
* Add Python 3.8 statistics functions and classes
* Remove obsolete sys.subversion
* Add sys.unraisablehook
* Add threading.excepthook
* Add get_native_id() and Thread.native_id
* Add Python 3.8 tkinter methods
* Add CLOCK_UPTIME_RAW
* Add SupportsIndex
* Add typing.get_origin() and get_args()
* Add unicodedata.is_normalized
* Add unittest.mock.AsyncMock

Currently this is just an alias for Any like Mock and MagicMock. All of
these classes should probably be sub-classing Any and add their own
methods. See also #3224.

* Add unittest cleanup methods
* Add IsolatedAsyncioTestCase
* Add ElementTree.canonicalize() and C14NWriterTarget
* cProfile.Profile can be used as a context manager
* Add asyncio task name handling
* mmap.flush() now always returns None
* Add posonlyargcount to CodeType
2019-10-14 09:53:48 +02:00
Guido van Rossum
b336182b69 Fix some errors with --disallow-any-generics (#3276)
See #3267. Covers all of stdlib/2and3.
2019-09-29 09:15:27 -07:00
Jelle Zijlstra
d05a9d3d83 Improve enums (#3168)
I realized while working on srittau/type-stub-pep#64 that a
few things we do in existing enum definitions in typeshed are
problematic:

- Using "= ..." doesn't allow type checkers to correctly type the
  result of Enum.MEMBER.value. In fact, mypy at least infers
  .value to be "Ellipsis" if you do this.
- Properties on the enum values themselves, like HTTPStatus.phrase,
  should not be specified directly as attributes, because it makes
  type checkers think that the properties themselves are enum
  members.

I ended up doing a bit more cleanup to the signal module:
- Remove unnecessary ... initializers.
- Remove unnecessary _SIG = Signals alias.
- I don't have Windows to test, but the C code for _signal suggests
  that CTRL_C_EVENT and CTRL_BREAK events are not Signals, but just ints:
  1dbd084f1f/Modules/signalmodule.c (L1575)
2019-08-05 08:08:57 -07:00
Sebastian Rittau
dad16f2d43 Update socket exceptions (#3127)
* error is an alias for OSError in Python 3
* herror and gaierror can be constructed without arguments (tested
  in Python 2.7 and 3.7)
* timeout uses the same arguments as herror and gaierror
2019-07-18 16:50:28 -07:00
Matthew Wilkes
d149fe435c Represent the use of IntEnums in functions in socket.py. (#3009)
The Pull Request #1121 added the `AddressFamily` type to `socket.pyi`
for Python 3.4+, so constants such as `AF_INET` are correctly
represented as being an enum member rather than an int. The same is
true of the `SocketKind` enums in the `SOCK_*` family.

Various functions in the socket module can accept either an int
or an `AF_*` enum member as arguments, which is allowed by the
int argument type. However the `getaddrinfo` function returns an
`AddressFamily` member rather than an int in the first position
of its list members, so code that access enum specific members
such as the `name` attribute causes a typing error to be found.

This change corrects the return type of `getaddrinfo` but leaves
the family parameters as int, given that `AddressFamily` members
are `IntEnum` and only ever treated as `int`s internally.
2019-06-19 15:14:15 -07:00
Jelle Zijlstra
ff650d3275 socket: add .set_inheritable() (#2935) 2019-04-28 17:13:20 +02:00
Philipp Hahn
b022f76516 socket: timeout may be None (#2801)
timeout=None puts the socket into blocking mode.

Read <https://bugs.python.org/issue18417> and the referenced other
issues for more gory details.
2019-02-18 11:32:25 +01:00
Ville Skyttä
9b5976e15b socket: Some more address typing (#2695) 2018-12-20 19:45:29 -08:00
PRAJWAL M
c0d181605e Make backlog parameter optional in listen method (#2553) 2018-10-25 18:14:39 +02:00
Sebastian Rittau
006a79220f Flake8 fixes (#2549)
* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
2018-10-24 07:20:53 -07:00
Ville Skyttä
066d8becf9 socket.create_connection source_address can be bytes or bytearray too (#2370)
* socket.create_connection source_address can be bytes or bytearray too

* Sync applicable socket.create_connection changes to socket.getaddrinfo
2018-08-09 10:02:34 -07:00
Ville Skyttä
850d16a668 socket.recv* return type improvements (#2363) 2018-08-09 08:07:17 -07:00
Yusuke Miyazaki
6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -07:00
Andrew Svetlov
a5b7ddd96c Accepy bytes in sock.connect() and family (#2252) 2018-06-18 10:30:41 -07:00
Jelle Zijlstra
f65caed181 allow socket.recv_into to take a memoryview (#2127)
Fixes #1862
2018-06-11 14:25:11 -07:00
Dmitry Figol
f7f00c52af socket.create_connection allows host to be None (#2136) 2018-05-17 09:45:59 -04:00
hashstat
0917560195 Add new methods to socket stubs. (#1638)
* Add new methods to socket stubs.

Also fix a couple of invalid types in recv*_into() socket methods.

* Add double-underscores to parameters for position-only arguments
2017-10-07 08:41:06 -07:00
hashstat
6661377597 Ensure AF_*, SOCK_*, AI_*, and MSG_* constants use enum types (#1637) 2017-10-04 08:55:36 -07:00
Dominik Gabi
693509bff6 Change Union[float, None] to Optional in socket.pyi (#1602) 2017-09-13 13:23:54 -07:00
Harmen
d260bb4889 support for with socket.create_connection (#1429) 2017-06-24 09:11:12 -07:00
Jelle Zijlstra
c31dcf4088 Add more flags to socket (#1348)
Also switch to PEP 526-style types in socket.
2017-05-26 08:25:20 -07:00
David Euresti
f741429a75 Move socket into 2and3 (#1149)
* Merge socket modules

* Move socket to 2and3
2017-04-07 18:01:33 -07:00