Commit Graph

12444 Commits

Author SHA1 Message Date
Raymond Hettinger 7709037095
Small speed-up for the convolve() recipe. (GH-106371) 2023-07-03 15:38:38 -05:00
Mario Corchero d65b783b69
gh-61215: New mock to wait for multi-threaded events to happen (#16094)
mock: Add `ThreadingMock` class

Add a new class that allows to wait for a call to happen by using
`Event` objects. This mock class can be used to test and validate
expectations of multithreading code.

It uses two attributes for events to distinguish calls with any argument
and calls with specific arguments.

The calls with specific arguments need a lock to prevent two calls in
parallel from creating the same event twice.

The timeout is configured at class and constructor level to allow users
to set a timeout, we considered passing it as an argument to the
function but it could collide with a function parameter. Alternatively
we also considered passing it as positional only but from an API
caller perspective it was unclear what the first number meant on the
function call, think `mock.wait_until_called(1, "arg1", "arg2")`, where
1 is the timeout.

Lastly we also considered adding the new attributes to magic mock
directly rather than having a custom mock class for multi threading
scenarios, but we preferred to have specialised class that can be
composed if necessary. Additionally, having added it to `MagicMock`
directly would have resulted in `AsyncMock` having this logic, which
would not work as expected, since when if user "waits" on a
coroutine does not have the same meaning as waiting on a standard
call.

Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
2023-07-03 07:56:54 +01:00
Terry Jan Reedy 04dfc6fa90
gh-106232: Make timeit doc command lines compatible with Windows. (#106296)
Command Prompt (CMD Shell) and older versions of PowerShell
require double quotes and single quotes inside the string.
This form also works on linux and macOS.
2023-06-30 22:34:31 -04:00
F3eQnxN3RriK a8ae73965b
gh-101100: Docs: Fix references to several numeric dunders (#106278)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-30 15:27:09 +01:00
Brandt Bucher 7b2d94d875
GH-106008: Make implicit boolean conversions explicit (GH-106003) 2023-06-29 13:49:54 -07:00
hms 8bff940ad6
gh-105775: Convert LOAD_CLOSURE to a pseudo-op (#106059)
This enables super-instruction formation,
removal of checks for uninitialized variables,
and frees up an instruction.
2023-06-29 09:34:00 -07:00
F3eQnxN3RriK 18f51f91e2
gh-101100: Fix reference to `parse_args` in `optparse.rst` (#105265) 2023-06-28 15:30:26 +03:00
F3eQnxN3RriK bbf722dcd3
gh-101100: Fix reference to asynchronous methods (#106172) 2023-06-28 10:43:11 +00:00
Sam Bull 6b52a581c1
gh-105993: Add possible `None` return type to `asyncio.EventLoop.start_tls` docs (#105995) 2023-06-28 16:08:15 +05:30
lightdrk 541a10f9ed
Refer to `TimeoutError` instead of `asyncio.TimeoutError` in `asyncio-task.rst` (#106136)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-06-27 23:21:38 -06:00
Nikita Sobolev 33608fd67d
gh-92788: Add docs for `ast.Module`, `ast.Expression`, and others (#101055) 2023-06-27 06:43:49 -07:00
Raymond Hettinger a8210b6df1
GH-105774: Clarify operation of normalize() (GH-106093) 2023-06-26 23:12:22 -05:00
Łukasz Langa d3af83b934
Revert "GH-96145: Add AttrDict to JSON module for use with object_hook (#96146)" (#105948)
This reverts commit 1f0eafa844.
2023-06-26 20:35:53 +02:00
Roderich Schupp 512f299e55
gh-106107: document correct error that's raised when a mutable default value for a field is detected (gh-106109) 2023-06-26 14:00:21 -04:00
Barney Gale 219effa876
GH-105793: Add follow_symlinks argument to `pathlib.Path.is_dir()` and `is_file()` (GH-105794)
Brings `pathlib.Path.is_dir()` and `in line with `os.DirEntry.is_dir()`, which
will be important for implementing generic path walking and globbing.
Likewise `is_file()`.
2023-06-26 17:58:17 +01:00
Paul Moore 5d4dbf0e30
gh-106111: Remove zipapp documentation on creating a Windows executable (#106112)
Remove zipapp documentation on creating a Windows executable
2023-06-26 18:14:20 +02:00
Alex Waygood 3eeb8c8906
Improve typing docs on the type of class objects (#106081) 2023-06-26 00:13:48 -07:00
Erlend E. Aasland bef1c8761e
Docs: add links to 'callable' term in sqlite3 docs (#106072) 2023-06-25 02:02:59 +02:00
Barney Gale 4a6c84fc1e
GH-104375: Use `versionchanged` to describe new arguments in pathlib docs (GH-104376) 2023-06-24 16:14:09 +01:00
Eamon Tracey 8ef0ee4ebc
Typing docs: fix typo in annotating tuples comment (#106048) 2023-06-23 21:34:05 +01:00
Irit Katriel d8ca5a11bc
gh-105730: support more callables in ExceptionGroup.split() and subgroup() (#106035) 2023-06-23 19:47:47 +01:00
Alex Waygood 968435ddb1
Typing docs: improve the guidance on annotating tuples (#106021) 2023-06-23 15:33:20 +01:00
Barney Gale a8006706f7
GH-89812: Add `pathlib.UnsupportedOperation` (GH-105926)
This new exception type is raised instead of `NotImplementedError` when
a path operation is not supported. It can be raised from `Path.readlink()`,
`symlink_to()`, `hardlink_to()`, `owner()` and `group()`. In a future
version of pathlib, it will be raised by `AbstractPath` for these methods
and others, such as `AbstractPath.mkdir()` and `unlink()`.
2023-06-22 14:35:51 +01:00
Mathieu Dupuy c5a722be5f
stdtypes.rst: remove a period (#105959) 2023-06-21 15:21:37 +01:00
Alex Waygood 4426279a43
typing docs: Improve the intro to each section (#105901) 2023-06-19 00:54:29 +01:00
Erlend E. Aasland 6849acb3fe
gh-105875: Require SQLite 3.15.2 or newer (#105876)
SQLite 3.15.2 was released 2016-11-28.
2023-06-19 00:29:08 +02:00
Irit Katriel 14d01262da
gh-105481: remove HAS_ARG, HAS_CONST, IS_JUMP_OPCODE, IS_PSEUDO_OPCODE and replace by their new versions (#105865) 2023-06-17 17:00:16 +01:00
Carl Meyer b356a4749a
gh-105678: document SET_FUNCTION_ATTRIBUTE (#105843) 2023-06-16 12:36:59 -05:00
Alex Doe 486b52a315
bpo-44530: Document the change in MAKE_FUNCTION behavior (#93189)
* bpo-44530: Document the change in MAKE_FUNCTION behavior

Fixes dis module documentation for MAKE_FUNCTION due to 2f180ce2cb (bpo-44530, released as part of 3.11) removes the qualified name at TOS
2023-06-15 19:04:57 -05:00
Alex Waygood da911a6b22
More reorganisation of the typing docs (#105787) 2023-06-15 06:52:18 +01:00
Alex Waygood 006a453205
Improve docs for `typing.dataclass_transform` (#105792) 2023-06-15 06:51:42 +01:00
Mark Shannon 1d857da7f0
GH-77273: Better bytecodes for f-strings (GH-6132) 2023-06-14 16:15:08 +01:00
Alex Waygood 7b1f0f204a
gh-105570: Deprecate unusual ways of creating empty TypedDicts (#105780)
Deprecate two methods of creating typing.TypedDict classes with 0 fields using the functional syntax: `TD = TypedDict("TD")` and `TD = TypedDict("TD", None)`. Both will be disallowed in Python 3.15. To create a TypedDict class with 0 fields, either use `class TD(TypedDict): pass` or `TD = TypedDict("TD", {})`.
2023-06-14 14:58:41 +00:00
Alex Waygood 4a113e24a3
Typing docs: move the deprecated stuff below the non-deprecated stuff (#105781) 2023-06-14 15:19:27 +01:00
Alex Waygood ad56340b66
gh-105566: Deprecate unusual ways of creating `typing.NamedTuple` classes (#105609)
Deprecate creating a typing.NamedTuple class using keyword arguments to denote the fields (`NT = NamedTuple("NT", x=int, y=str)`). This will be disallowed in Python 3.15. Use the class-based syntax or the functional syntax instead.

Two methods of creating `NamedTuple` classes with 0 fields using the functional syntax are also deprecated, and will be disallowed in Python 3.15: `NT = NamedTuple("NT")` and `NT = NamedTuple("NT", None)`. To create a `NamedTuple` class with 0 fields, either use `class NT(NamedTuple): pass` or `NT = NamedTuple("NT", [])`.
2023-06-14 13:38:49 +01:00
Jelle Zijlstra fc8037d84c
gh-104873: Add typing.get_protocol_members and typing.is_protocol (#104878)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-14 05:35:06 -07:00
Jelle Zijlstra 5cdd5ba49d
tarfile: Fix positional-only syntax in docs (GH-105770)
The syntax used in the current docs (a / before any args) is invalid.

I think the right approach is for the arguments to arbitrary
filter functions to be treated as positional-only, meaning that users
can supply filter functions with any names for the argument. tarfile.py
only calls the filter function with positional arguments.
2023-06-14 09:26:48 +02:00
zentarim f3266c05b6
GH-104554: Add RTSPS support to `urllib/parse.py` (#104605)
* GH-104554: Add RTSPS support to `urllib/parse.py`

RTSPS is the permanent scheme defined in
https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
alongside RTSP and RTSPU schemes.

* 📜🤖 Added by blurb_it.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-06-13 16:45:47 -07:00
Jay f0fb782ddb
gh-105331: Change `asyncio.sleep` to raise ``ValueError` for nan (#105641)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-06-12 20:29:02 +00:00
Tomas R 18d16e93b6
gh-102676: Add more convenience properties to `dis.Instruction` (#103969)
Adds start_offset, cache_offset, end_offset, baseopcode,
baseopname, jump_target and oparg to dis.Instruction.

Also slightly improves the disassembly output by allowing
opnames to overflow into the space reserved for opargs.
2023-06-11 08:50:34 -07:00
Hugo van Kemenade cc879481e2
gh-80480: Emit DeprecationWarning for array's 'u' type code (#95760) 2023-06-11 03:17:35 -06:00
Gregory P. Smith 3a314f7c3d
gh-99108: Mention HACL\* in the hashlib docs. (#105634) 2023-06-10 12:09:20 -07:00
Gregory P. Smith 0d1d6ab966
Cleanup and clarify our hashlib docs. (#105624)
Clarify and improve our hashlib docs. Now with 50% less mess!
2023-06-10 11:49:06 -07:00
Pablo Galindo Salgado 1dd267af64
Clarify the supported cases in the tokenize module (#105569) 2023-06-09 16:59:37 +01:00
Alex Waygood 8e755923c9
Miscellaneous improvements to the typing docs (#105529)
Mostly, these are changes so that we use shorter sentences and shorter paragraphs. In particular, I've tried to make the first sentence introducing each object in the typing API short and declarative.
2023-06-09 15:08:57 +00:00
Nikita Sobolev 947ec7ab02
gh-105545: Remove deprecated `MacOSXOSAScript._name` (gh-105546) 2023-06-09 08:52:58 +00:00
Alex Waygood d213c2990f
Further improve docs for `typing.Annotated` (#105498) 2023-06-08 14:36:30 +00:00
Alex Waygood fbdee000de
gh-90015: Document that PEP-604 unions do not support forward references (#105366) 2023-06-07 18:26:23 +01:00
Alex Waygood d63a7c3694
typing: Improve documentation of generic classes and aliases (#105369) 2023-06-07 14:02:40 +00:00
Alex Waygood e26d296984
gh-97797: Improve documentation for typing.Annotated (#105365) 2023-06-07 06:35:34 -07:00