Skip to content

[4.x] Backport #1547, #1566, #1567 and #1551 - #1578

Merged
laughingman7743 merged 37 commits into
4.xfrom
backport/4.x-1547-1551
Nov 30, 2026
Merged

laughingman7743 merged 37 commits into
4.xfrom
backport/4.x-1547-1551

Conversation

@laughingman7743

@laughingman7743 laughingman7743 commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

WHAT

The sixth batch of the 4.x backports decided in #1327 (comment): the master PRs merged after #1556, up to #1551, in master merge order, preceded by the rest of #1538. Each commit is a git cherry-pick -x of the master commit.

Follows #1568 (merged); the branch was updated with 4.x after that merge, with no change to its tree.

Master PR Issue Commits Change on 4.x
#1538 (ce72fcc) #1510 a8afdaa (its 81123d5 is in #1560) cp_file() looks up the object that it copies, as parsed: cp_file("s3://bucket/dir/", dst) copies a folder marker dir/ instead of skipping it as a directory; cp_file("s3://bucket/k/", dst) with only k raises FileNotFoundError before any copy; cp_file("bucket//", dst) looks up the key /; the size that selects CopyObject or a multipart copy comes from the copied object. copy()/mv() with lists of sources and destinations copy (and mv() deletes) a marker path given in such a list.
#1547 (7611e6a) #1503 all 14 A time-travel hint (FOR VERSION AS OF, ...) on an aliased table is placed between the table and its alias through SQLAlchemy's hint hook; the table keeps its quoting and schema_translate_map.
#1566 (11e826c) #1563 all 2 The dialect compiles update() on SQLAlchemy 2.1, which 4.x's sqlalchemy>=2.0.23 also allows.
#1567 (07f34d4) #1513, #1564 all 9 The test connection helpers move to tests/pyathena/util.py, and duplicate offline tests are removed. Tests only.
#1551 (0255e1f) #1491 all 10 A version ID query is read only after a key and not as a glob; a bucket path with a version raises ValueError.

a8afdaa (#1538 item 1), first proposed as master only, is included by the maintainer's decision in the review of this PR: without it, #1551 makes cp_file("s3://bucket/k?versionId=/", dst) read the key k?versionId=/ but look up k?versionId= (without the trailing slash), so with only that object it found a directory and copied nothing. With a8afdaa the lookup uses the parsed source. a8afdaa applies without conflict and its patch equals master's.

Conflicts and missing prerequisites (each recorded in its commit message, resolved with the commit's own delta):

The #1551 handoff (#1491) expected a docs conflict in 9dd4e44; it applies cleanly, because #1545 (backported in #1554) already added the expires_string sentence to the setxattr() paragraph.

Release notes (from the master PRs):

  • Look up the object that cp_file() copies, and leave the bucket out of a recursive copy (GH-1510) #1538 item 1 (behavior change): cp_file() uses the source key as written, also for its lookup: a folder marker path such as s3://bucket/dir/ is copied instead of skipped, cp_file("s3://bucket/k/", dst) with only k raises FileNotFoundError before any copy, and cp_file("bucket//", dst) copies the key /. copy() and mv() with lists of both sources and destinations copy a marker path given in such a list, and mv() deletes it.

  • Render the time-travel hint of an aliased table before its alias #1547: a time-travel hint on an aliased table keeps the table's quoting and schema_translate_map; an unaliased table whose rendered name contains AS no longer raises; a subquery's hint is no longer applied to the tables inside it; an empty hint leaves no trailing space (SQLAlchemy's default hint rendering).

  • Compile update() on SQLAlchemy 2.1 (GH-1563) #1566: update() compiles on SQLAlchemy 2.1. With 2.1, an element or slice expression passed more than once to ordered_values() keeps only its last value, where 2.0 raises CompileError.

  • Read a version ID query only after a key, and not as a glob (GH-1491) #1551 (behavior change): a bucket path with a version (bucket?versionId=v1, bucket/?versionId=v1) raises ValueError; a ?versionId= query whose ID is empty or only slashes is part of the key everywhere and is not expanded as a glob, so rm("s3://bucket/key?versionId=") no longer deletes keyXversionId=; rm("s3://bucket//?versionId=v1") deletes that version of the key /; copy()/mv() into a directory such as key?versionId=/ writes key?versionId=/k.

WHY

#1327 decided to backport the fixes merged to master after the 4.x cut in one session, in master merge order. This PR continues after #1568.

TEST

Tested commit: 91c5ec1, on #1568's head (83e748e); the current head 06a8fe0 (4.x merged in) has the same tree.

🤖 Generated with Claude Code

from collections.abc import Mapping
from itertools import product
from typing import TYPE_CHECKING, Any, cast
from typing import TYPE_CHECKING, Any, ClassVar, cast

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round 1 (implementation behavior): CLEAN

Scope: git diff 864621f8ed7734f145aba2c0397750f722c43fff..f81120abe6634f65597d286fde44030acec01d60 (35 commits: #1547 ×14, #1566 ×2, #1567 ×9, #1551 ×10).

Covered:

Findings: none introduced by the backport.
Limits: SQLAlchemy compliance suites and AWS tests run in CI on Ready.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction to this record: the sentence on how 1535f6f's missing import was found is wrong. It was found while resolving 7c08bd0: after its typing import was resolved to the 4.x line plus NamedTuple, ruff reported F821 Undefined name ClassVar for _TIME_TRAVEL_HINTS, which 1535f6f had added. The #1547 backport was then rebuilt with ClassVar imported in 1535f6f. The per-commit ruff check of the final series passes at every commit.

from collections.abc import Mapping
from itertools import product
from typing import TYPE_CHECKING, Any, cast
from typing import TYPE_CHECKING, Any, ClassVar, cast

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round 2 (claims, callers, operations): CLEAN

Claims checked:

Existing callers: #1551 is a behavior change (release-noted). #1547 changes rendered SQL only for hints on aliases and the cases listed. Operations: none of these change request counts outside #1551's paths.

from collections.abc import Mapping
from itertools import product
from typing import TYPE_CHECKING, Any, cast
from typing import TYPE_CHECKING, Any, ClassVar, cast

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (relayed): Codex CLI 0.172.0, model gpt-6.2-astra, reasoning effort max, codex exec -s read-only, session 01a22b71-05c5-7cf3-a4c4-ed88f12cf29d. Static review only.

Scope: 864621f8ed7734f145aba2c0397750f722c43fff..f81120abe6634f65597d286fde44030acec01d60, a detached snapshot of the head (unchanged afterwards); the prompt named the master merges, the master-only commits behind the import additions, and the 4.x SQLAlchemy floor.

Coverage: all 35 cherry-picks ("the only difference in added or removed lines is the ClassVar import required on 4.x"); alias rendering, schema translation, ORM aliases and ordered ARRAY updates against SQLAlchemy 2.0.23, later 2.0.x and 2.1.9 ("the required compiler hooks exist at the 4.x floor"); S3 parsing, globbing, cache invalidation, copy/move pairing, aio delegation; connection=/s3_filesystem, touch(), underscore keys; the consolidated tests ("the 4.x-only tests retain their coverage and AWS fixture requirements").

FINDINGS:

  1. 4.x-specific: cp_file("s3://bucket/k?versionId=/", dst) with only the object k?versionId=/ looks up k?versionId= (the path without its trailing slash), finds the directory, and copies nothing (s3.py:3508, s3_async.py:1474). Verified with Read a version ID query only after a key, and not as a glob (GH-1491) #1551's harness (sync cp_file rows: before Read a version ID query only after a key, and not as a glob (GH-1491) #1551, 4.x read the path as version / of key and raised FileNotFoundError). On master, a8afdaa looks up the parsed source; it is master only (it changes what cp_file() of a folder-marker path copies), so on 4.x such a key is treated as cp_file() treats s3://bucket/dir/ with a marker dir/: as a directory. Put to the maintainer; not changed yet.
  2. tests/sqlalchemy/test_suite.py:462 expects SQLAlchemy 2.0's result for ~(any_(flags) == True); on 2.1 the compliance test would fail. The same on master (file identical) → Fix the defects that the 4.x backport reviews found in master (get() checks, concurrent close, docs, tests) #1565.
  3. docs/filesystem.md:758 extends the bucket-version ValueError to fsspec.open_files(), whose default expansion globs ?. The same text on master (master docs/filesystem.md:779) → Fix the defects that the 4.x backport reviews found in master (get() checks, concurrent close, docs, tests) #1565.
  4. The consolidated engine test (test_base.py:1854) no longer checks that duration_seconds and verify reach the DB-API connection. From master's Move the test connection helpers to tests/pyathena/util.py and remove duplicate offline tests (GH-1513, GH-1564) #1567 → Fix the defects that the 4.x backport reviews found in master (get() checks, concurrent close, docs, tests) #1565.
  5. placeholder_connection() docstring: already Fix the defects that the 4.x backport reviews found in master (get() checks, concurrent close, docs, tests) #1565 item 6.6.
  6. test_s3.py:694 and test_s3_path_pairing.py:247 match undocumented exception wording; from master's Read a version ID query only after a key, and not as a glob (GH-1491) #1551 → Fix the defects that the 4.x backport reviews found in master (get() checks, concurrent close, docs, tests) #1565.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repair of finding 1 (maintainer's decision: include a8afdaa): f81120a → 91c5ec1, pushed with --force-with-lease

The branch was rebuilt on #1568's current head 83e748e: git cherry-pick -x a8afdaa3 (#1538 item 1, in master order before #1547), then the 35 commits of the previous series unchanged. git diff f81120ab 91c5ec13 has the patch-id of a8afdaa, and every other commit keeps its patch-id.

Self-review of the repair, round 1 (behavior): CLEAN.

Round 2 (claims, callers): CLEAN. The PR body adds a8afdaa's row, its release note (taken from #1538's body: marker paths are copied, cp_file("s3://bucket/k/") with only k raises before any copy, bucket// copies the key /, list-to-list copy()/mv() copy and delete marker paths), and the new test numbers. This is a behavior change for 4.x callers that relied on cp_file() skipping a marker path; it is release-noted.

An independent follow-up of the expanded scope is requested.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up of the expanded scope (relayed): Codex CLI 0.172.0, gpt-6.2-astra, effort max, read-only, session 01a22b96-cd42-7dd1-825b-d0d236446d67. Static. Scope: the first commit of 83e748ed..91c5ec13 (a8afdaa) in full, in the 4.x context, and git range-diff 864621f8..f81120ab 83e748ed..91c5ec13 (snapshot unchanged afterwards).

Coverage: the five files of the a8afdaa backport match master's hunks; "the range-diff marks all 35 later patches as equivalent, and the final path parser and copy-pairing code match 0255e1f0"; the interfaces it uses exist on 4.x; connection=, s3_filesystem, touch()'s to_dict() keep their 4.x behavior; the reported case is fixed (with only k?versionId=/, lookup and copy use that literal key).

FINDINGS (both also on master, so they are not changed in the backport; added to #1565 as items 7 and 8):

  1. With only dir/child, cp_file("s3://bucket/dir/", dst) skips the directory on a cold cache but raises FileNotFoundError after fs.ls("s3://bucket/dir") (s3.py:3509, s3_cache.py:418). Verified offline with serve_s3_keys: 4.x before a8afdaa skips in both cases; this branch, master a8afdaa and the current master raise on the warm cache. It comes with a8afdaa as on master; the fix goes to master first and is then backported.
  2. docs/filesystem.md:776 says that a write to bucket// such as pipe_file() raises ValueError, but cp_file(src, "s3://bucket//") copies to the key /. The same text on master (line 794).

laughingman7743 and others added 26 commits November 30, 2026 17:14
_copy_file() of S3FileSystem and AioS3FileSystem copied the object of
the path parsed as written, but took its type and size from
_info_entry() of the path, which strips a trailing slash. The lookup
and the copy then addressed different objects:

- cp_file("s3://bucket/k/", dst) looked up "k" and sent CopyObject for
  "k/", which failed with NoSuchKey.
- cp_file("s3://bucket/dir/", dst) of a folder marker "dir/" looked up
  "dir", found the directory, and skipped the copy.

The size decides between CopyObject and a multipart copy, so it could
also come from the other object. _copy_file() now looks up the S3Path
that it copies, with the same lookup parameters. A folder marker is
copied, and a path whose key does not exist raises FileNotFoundError
before any copy. copy() and mv() with lists of both sources and
destinations, which pair the paths as given and copy them as
cp_file() does, now copy (and, for mv(), delete) such a marker too.
This changes what cp_file() of a marker path copies, so it is for
master only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a8afdaa)
…1503)

visit_alias() passes a FOR ... AS OF hint of an alias of a table
(through nested aliases) to the table visit, which renders it between
the table and the alias, so the table keeps SQLAlchemy's quoting and
schema_translate_map. The format_from_hint_text() override, which split
the rendered alias text on " AS " and used the table's unquoted
fullname, is removed: an unaliased table whose name renders with "AS"
(BASIC, "my AS t") no longer raises, and other hints keep SQLAlchemy's
default placement after the alias.

Backport (4.x): this commit annotates _TIME_TRAVEL_HINTS with ClassVar
in pyathena/sqlalchemy/compiler.py, whose typing import came on master
with 83837ab (#1531, master only). ClassVar is added to the typing
import here; nothing else changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1535f6f)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f041596)
An ORM aliased() entity reaches visit_alias() as an annotated copy that
is equal to the hint's key but not identical to it, so filtering the
hints by identity kept the hint, and SQLAlchemy rendered it again after
the alias. The hint is now deleted by key. Tests cover the ORM alias,
split the unaliased names into their own test, and check that a
subquery's tables are rendered without the hint instead of asserting
where the hint itself lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 254f508)
visit_alias() walks to the aliased table only after the hint matches,
and visit_table() passes the table's hint alone, since the table is the
only key it reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a5390fc)
…GH-1503)

visit_alias() and visit_table() take SQLAlchemy's positional parameters
through *args and read fromhints and the time-travel hint from the
keyword arguments, so a compiler extension that delegates with a
positional asfrom keeps working. The subquery test asserts the whole
statement again, so it also fails if the hint is dropped, and the
documentation example shows the SQL that its select() builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e9642ff)
…H-1503)

visit_alias() and visit_table() declare SQLAlchemy's asfrom, ashint,
iscrud and fromhints in their original positions and pass every
argument to the base class in the same position, so a compiler
extension that delegates with fromhints given positionally keeps the
time-travel hint before the alias, and the table visit no longer
receives fromhints twice. The internal hint is keyword-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 6a07480)
visit_alias() and visit_table() forward their positional and keyword
arguments unchanged and replace only fromhints, in the place where the
caller passed it, when a time-travel hint is moved to the table. A
compiler that follows the Athena compiler in the MRO with keyword-only
hooks receives the same call as from SQLAlchemy, and an extension that
delegates with positional arguments keeps the hint before the alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8288b9a)
…rnal keyword (GH-1503)

visit_alias() looks the alias up only when fromhints is not empty, as
SQLAlchemy does, and the hint passed to the table visit is named
athena_time_travel_hint so that a caller's own compile keyword is not
rendered as a hint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 36d5590)
visit_alias() passes the hint as a private str subclass, and
visit_table() takes the keyword only when its value has that type, so
a caller's compile keyword of the same name is passed on unchanged and
never replaces or drops a table's hint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 430595c)
The marker that carries the hint to the table visit is a NamedTuple
that holds the hint as given, instead of a str subclass built from it,
so a hint whose str() differs from its value, such as a str-valued
Enum member, renders as its value.

Backport conflict (4.x): tests/pyathena/sqlalchemy/test_compiler.py.
On master, the new _VersionHint class goes before _FormattedInt, which
6f04c6c (#1531, master only) added and 4.x does not have. Resolved with
this commit's own delta only: _VersionHint is added in that place, without
_FormattedInt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7c08bd0)
SQLCompiler.visit_alias() calls format_from_hint_text() with the
rendered table followed by the alias suffix. For a time-travel hint on
an alias of a table, the override now inserts the hint before that
suffix, computed from SQLCompiler.visit_alias(ashint=True), and passes
the rest to SQLAlchemy's formatting. This replaces the visit_alias()
and visit_table() overrides, the hint marker and the keyword that
carried it, so compiler extensions see SQLAlchemy's own calls. If the
rendered text does not end with the suffix, SQLAlchemy's default
placement applies. An aliased UPDATE or DELETE target gets the hint
before its alias, as on master. Tests that covered the removed keyword
and argument handling are replaced by a hook that appends text to every
alias and a LATERAL subquery case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f3dc4d4)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5a44b39)
…GH-1503)

format_from_hint_text() walks FromClauseAlias elements once to tell an
alias of a table, and drops a hint guard that SQLAlchemy's str hints
never need. The new tests compile through _compile_sql().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 387c452)
…ing hook (GH-1503)

The aliased cases use a table name that contains AS, so splitting on the
first " AS " fails them, and the appending hook also renders an UPDATE
target, whose text ends after the hook's comment, so removing the suffix
check truncates it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4770a18)
SQLAlchemy 2.1 removed Update._ordered_values, which the ARRAY assignment
rewrite read for every UPDATE, so every update() raised AttributeError.
The rewrite now reads it only where it exists; on 2.1 the values of
ordered_values() are in _values, whose order _maintain_values_ordering
keeps and _clone() copies. _ArrayUpdate.rewrite() gets a docstring.

test_quantifier_boolean_left_operand compiled a negated quantifier
comparison that SQLAlchemy 2.0 turns into a != comparison and 2.1 negates
as a whole. It now compiles the != comparison itself and keeps the check of
the grouped negation, so it no longer depends on the SQLAlchemy version.
The docs name the two versions in their note on negation and say that
SQLAlchemy 2.1 deprecates array.any() and array.all().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 34a11bc)
)

SQLAlchemy 2.1 keeps only the last value of a key object passed more than
once to ordered_values(), before the dialect sees the statement, so that
statement assigns the last value where SQLAlchemy 2.0 raises CompileError.
The docs and the docstring of _ArrayUpdate.rewrite() say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ef0d5a1)
…GH-1513)

test_connection.py had its own copy of the placeholder settings and
credentials. The aio module keeps its helper, which awaits
AioConnection.create().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7a44fba)
…GH-1513)

connect(), connect_aio() (was the aio conftest's _aio_connect()),
create_test_engine() and create_async_test_engine() move out of the
conftests, and the test modules import them, and ENV from tests, at the
top of the file. The engine helpers are renamed because util.py already
imports SQLAlchemy's create_engine().

Both engine helpers accept the same connection options, ENGINE_OPTIONS,
and raise TypeError on any other key; create_async_engine() used to drop
every option but unload, and create_engine() ignored unknown keys. The
three Spark cursor fixtures apply one work_group rule: the Spark work
group replaces a work_group of the indirect parameter, which
aio_spark_cursor used to reject with TypeError. The fixtures no longer
change the indirect parameter's dict.

Backport conflict (4.x): the sqlalchemy import of tests/pyathena/util.py.
On master, 1ef1f0f (#1508, master only) had turned the names imported
from sqlalchemy into a longer parenthesized list, which 4.x does not
have. Resolved with this commit's own delta only: the 4.x import line is
kept, and the sqlalchemy.engine and sqlalchemy.ext.asyncio imports that
the moved helpers need are added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4760383)
…ne engine test (GH-1513)

TestAthenaDialect::test_conn_str_numeric_options checks the conversion
of duration_seconds, poll_interval and result_reuse_minutes, and their
types, for both dialects, as test_conn_str_boolean_options does for the
boolean options. Together they check the conversion of the six options
that the TestSQLAlchemyAthena::test_conn_str_* tests set.

Those six tests are replaced by test_url_sets_connection_options, which
sets kill_on_interrupt, result_reuse_enable, poll_interval and
result_reuse_minutes in the URL of an engine and checks the public
attributes of its DB API connection. verify and duration_seconds are no
longer checked on the connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0d02cac)
TestConnection::test_cursor_arraysize_default and
test_cursor_arraysize_assignment check the default of 1000 and the rules
of assigning arraysize after construction for every paged and uncapped
cursor class, replacing the test_arraysize_default and
test_invalid_arraysize copies of ten cursor modules. Those compared the
default with an implementation constant and missed the Dict and aio
cursors.

TestCursor::test_cancel_initial and test_fetch_no_data keep the checks
of the inherited WithFetch methods, so the Arrow, Pandas, Polars and S3FS
copies of test_cancel_initial are removed, and the format-specific
test_fetch_no_data tests keep only their as_*() checks. The Polars one
adds as_arrow().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7c9be8f)
…st (GH-1513)

The old helper appended the options to the URL text, and SQLAlchemy
decoded them when it parsed the URL. create_test_engine() puts them in
the URL's query dict, which keeps them as given. The three live tests
that passed URL-encoded values now pass plain ones, so the dialect gets
the same values as before.

test_cursor_arraysize_assignment becomes one test for the paged cursors
and one for the uncapped cursors, as the constructor tests are split.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4c318b2)
…ne template (GH-1513)

aio_spark_cursor closed its cursor but not its connection, as
AioSparkCursor.close() leaves the connection open; it now closes the
connection too, also when the cursor cannot be created.

The sync and async connection strings of tests differ only in the
driver, which _engine_url() replaces, so it builds both engines' URLs
from SQLALCHEMY_CONNECTION_STRING.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4b40a1c)
…ment (GH-1513)

The default and assignment tests open their cursors on
offline_connection, as the per-module tests that they replace did, so a
cursor that calls AWS fails them and the connection is closed. The
assignment tests also reject -1, as those tests did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1f5510a)
…pped cursors (GH-1513)

The default and assignment tests open their cursors with
_opened_cursor(), which closes them, as the per-module tests that they
replace did with context managers. The uncapped cursors are assigned
10000, the value of those tests, so that a cap between 1001 and 10000
fails too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c826c3d)
…sing() (GH-1513)

As coroutines, the three tests took pytest-asyncio's implicit asyncio
mark. The listed cursor classes all close synchronously, so the tests
stay synchronous and close their cursors with contextlib.closing().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 6a59f62)
laughingman7743 and others added 10 commits November 30, 2026 17:15
S3Path.parse() follows the rule of GH-1481 that _strip_protocol() already
applied: a query whose version ID is empty or has only slashes names no
version and is part of the key, so "key?versionId=/" no longer names the
version "/" of "key" in the methods that parse the path as given.

A version ID query is read only after a key: "bucket?versionId=v1" and
"bucket/?versionId=v1" raise ValueError instead of naming a version of the
bucket path, while "bucket//?versionId=v1" stays the version v1 of the key
"/".

A path that ends in the form of a version ID query, also with an empty or
slash-only ID, is not a glob pattern, so rm(), mv(), copy(), cat(), get()
and expand_path() no longer expand its "?": rm("s3://bucket/key?versionId=")
deleted "keyXversionId=" as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0d74d99)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d848f20)
…() (GH-1491)

rm() rejected "bucket//?versionId=v1" as the bucket, while rm_file() and
mv() address the version v1 of the key "/": a path with a version is
deleted as given and never stripped to the bucket by expand_path().

S3Path.PATTERN keeps its form, and parse() rejects the bucket path with a
version that it matches, instead of a second copy of the query grammar in a
lookahead.

The docs state that a path ending in a query that names no version is not
a glob pattern also where wildcards occur before the query, and that the
listed name of a key such as "?versionId=v1" at the bucket root raises when
passed back. The tests check that mv() deletes what it copied and drop the
duplicate and repeated cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit fad097c)
A path with a version names an object, so is_bucket answers it, and rm()
asks it alone. The ls(), find() and chmod() checks for a version drop the
key condition that only a bucket path with a version needed, which parse()
no longer returns. The mv() test reads the copies with s3_copy_targets().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 30cefd5)
…ersions there (GH-1491)

copy() and mv() into a directory whose name ends in a query that names no
version, such as key?versionId=/, joined the source name to the string,
which parsed as the version "/k" of "key". A destination named below a
string path2 is now path2 parsed with the suffix added to its key, kept as
the string when that string names the same path. A bucket path with a
version as path2 is rejected there; a list of sources was moved below it as
the key "?versionId=v1/..." and deleted.

expand_path() parses the paths with a version ID, so a bucket path with a
version raises as in the other methods. invalidate_cache() of the listed
name of a key at the bucket root, such as bucket/?versionId=v1, evicts that
name only, not the other spellings of the query. S3Path.is_bucket stays
True for a path without a key. The docs name a version ID for setxattr()
and state that isfile() returns False for an invalid path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9dd4e44)
…ucket cases (GH-1491)

s3_copy_pairs() parses path2 only for a destination named below it or for
an S3Path source, so the contents of a directory copied to path2 itself
keep the destination that copy_pairs() names, which cp_file() checks.

Tests cover a string source copied into a directory at the bucket root
whose joined string is no S3 path, is_bucket of a path without a key, and
rm() of a bucket path with a version. The docs state the exceptions of
cat_ranges() and isfile(), the glob expansion of a list in
fsspec.open_files(), and the string path2 that s3_copy_pairs() needs to
return S3Path destinations; the expand_path() docstrings name the
ValueError of a path with a version ID.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 3f36973)
…H-1491)

The docs name both glob expansions of fsspec.open_files() (a string with
"*", and each path of a list with expand=True, which fsspec.open() uses
when expanding) and limit the ValueError of a bucket path with a version to
the methods that read it, besides invalidate_cache(), which invalidates the
listed name of a key at the bucket root. The s3_copy_pairs() docstring
defers the check of path2 itself only for a string source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d97b0fa)
…H-1491)

Instead of listing the modes in which fsspec.open_files() expands a path
as a glob pattern, the docs say that the compositions name the version
where fsspec does not expand the path. glob() reads a bucket path with a
version as a pattern, and s3_copy_pairs() does not parse the destination
of a string source that is path2 itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit b0e1f28)
The qualifier about fsspec's glob expansion is removed; how fsspec's
compositions read such names is recorded for the entry point work on the
issue instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f6e9e42)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 74353d2)
from collections.abc import Mapping
from itertools import product
from typing import TYPE_CHECKING, Any, cast
from typing import TYPE_CHECKING, Any, ClassVar, cast

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branch update after #1568 merged: review scope unchanged

gh pr update-branch merged 4.x (a6b5dc7, the merge of #1568) into this branch: head 91c5ec1 → 06a8fe0. The tree of a6b5dc7 equals that of 83e748e (the base of the reviewed series), and the tree of the new head equals that of 91c5ec1, so git diff a6b5dc7a..06a8fe0c is the reviewed diff.

@laughingman7743
laughingman7743 marked this pull request as ready for review November 30, 2026 08:47
@laughingman7743
laughingman7743 merged commit 13dc02b into 4.x Nov 30, 2026
16 checks passed
@laughingman7743
laughingman7743 deleted the backport/4.x-1547-1551 branch November 30, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant