You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR moves the project metadata to PEP 621 and Poetry 2, drops Python 3.9, adds ruff and mypy with a CI lint job, and adds a release workflow that publishes to PyPI when a v* tag is pushed. Running ruff and mypy over the code turned up six bugs, and each fix has its own commit.
Please review commit by commit. The style: commit 8c991e4 is unedited ruff output, so you can skim or skip it.
Breaking changes
Change
Who is affected
Python 3.9 is no longer supported. requires-python is now >=3.10.
Users still on 3.9
Sample.wherep() returns a list, as documented, instead of a set.
Code that calls .add() on the result, uses set operators on it, or compares it with == {...}
GridContainerPost sends cType: "GRID" instead of "LIST".
Anyone who relied on grid containers being created as list containers. This is unlikely to be intentional.
CHANGELOG.md lists all three under "Potentially breaking".
Changes
Packaging (0358362, 45e1535)
Project metadata moves from [tool.poetry] to the standard PEP 621 [project] table. Dev dependencies move to [dependency-groups], and the build backend is poetry-core 2.x.
CI uses Poetry 2.4.1, because Poetry 1.8 cannot read the [project] table.
poetry.lock is regenerated. main added fsspec and universal-pathlib to pyproject.toml without updating the lock file, so poetry check --lock failed after the rebase. The new lock adds fsspec, pathlib-abc and universal-pathlib and changes no existing pins.
Linting, formatting and typing (05c9696, 8c991e4, bc82e3a)
ruff replaces black for linting and formatting. mypy, pre-commit and pytest-cov are new dev dependencies, and all four tools are configured in pyproject.toml. ruff and mypy skip notebook_sync.
8c991e4 is the output of ruff check --fix followed by ruff format, with no manual edits.
bc82e3a fixes by hand what ruff could not fix automatically, and adds the annotations mypy needs to pass. These include PEP 604 unions, X | None for parameters that default to None, dict[str, Any] on self.data, and a ClientBase._get_api_url() stub. It also changes three behaviours:
Container.capacity() raises NotImplementedError instead of returning None.
The EXACT grid move zips items and locations with strict=True, so a length mismatch raises an error instead of silently dropping the extra items.
In examples/tree_upload.py, a bare exit did nothing. It is now sys.exit(1).
Bug fixes
dbd387f removes shared mutable default arguments. Several inv and eln methods had defaults such as Pagination(), tags=[], extra_fields=[], TopLevelTargetLocation(), item_ids=[] and typesToInclude=[]. Python creates a default once and every call that omits the argument shares it, so a SearchFilter merged into the default Pagination leaked into later calls. These parameters now default to None, and each call builds a fresh value.
f863a30 makes Sample.wherep() return a list, matching its annotation and docstring.
598073d makes GridContainerPost send cType: "GRID".
6cfdc59 adds the missing self to ListContainer.is_list(). Without it, calling the method on an instance raised TypeError.
f581c5b fixes the URL validator. Its error message was missing the f prefix and printed the literal {...} placeholders. It also used a bare except, which caught everything including KeyboardInterrupt. It now catches the ValueError that urlparse raises and chains it.
8323263 restores the server's error detail when an ELN export job fails. The + self._get_formated_error_message(...) line had no surrounding parentheses, so Python treated it as a separate statement and threw the result away. The error read only "Export job failed: ". ad8ce4f adds a test for this.
CI and release (83036f8, 6326a72)
A new lint job runs ruff check, ruff format --check and mypy rspace_client. The unit test job now waits for it.
The unit test matrix covers Python 3.10 to 3.13, up from 3.9 to 3.12. The integration job runs on 3.13.
The unit tests report coverage and fail if it drops below 55%.
The new release.yml workflow runs when a v* tag is pushed. It runs the unit tests, checks that the tag matches the version in pyproject.toml, builds the package and publishes it to PyPI. Publishing uses Trusted Publishing, which authenticates with OIDC, so no PyPI API token is stored anywhere.
release.sh now takes only the new version number. It bumps the version with poetry version, formats with ruff, then commits and tags. CI does the publishing.
Dependabot opens one grouped pull request a week for pip updates and one for GitHub Actions updates.
Tests (1213f8e, 32a8f3c, ad8ce4f)
Newer RSpace servers treat the DataCite password as write-only and return null for it. The DataCite settings test no longer asserts that the server echoes the password back.
The four DataCite tests used to overwrite the server's settings with dummy credentials and then fail to restore them. On a server with DataCite enabled, the restore passed password=None and raised ValueError. On a server with saved but disabled credentials, it left the dummy values behind. The tests now skip when DataCite is enabled or when real credentials are saved, and they always disable DataCite when they finish. CI and dev servers with no DataCite configuration still run them.
ad8ce4f adds a test for FAILED export jobs and moves the conda environment to Python 3.12.
Docs (3588123)
Updates the Unreleased section of CHANGELOG.md, DEVELOPING.md and the comments in pyproject.toml.
How to test
poetry install
poetry run ruff check rspace_client examples
poetry run ruff format --check rspace_client examples
poetry run mypy rspace_client
poetry run pytest -m "not integration" --cov=rspace_client
The integration tests still need a live RSpace server. Run them with poetry run pytest -m integration and the usual environment variables.
Move project metadata and dependencies from [tool.poetry] to the standard
[project] table and dev dependencies to [dependency-groups], with
poetry-core 2.x as the build backend. Python 3.9 is dropped.
CI moves to Poetry 2.4.1 (1.8 cannot read the [project] table) and the
unit test matrix becomes 3.10-3.13; the integration job runs on 3.13.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace black with ruff (lint + format) and add mypy, pre-commit and
pytest-cov as dev dependencies, with their configuration in
pyproject.toml. notebook_sync is excluded from ruff and mypy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Several methods used mutable or stateful defaults (Pagination(),
tags=[], extra_fields=[], TopLevelTargetLocation(), item_ids=[],
typesToInclude=[]). Those objects are created once and shared by every
call that omits the argument, so e.g. a SearchFilter merged into the
default Pagination leaked into later calls. Default to None and build a
fresh value per call.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wherep() is annotated and documented as returning a list of breadcrumb
strings but returned the de-duplicating set directly.
BREAKING CHANGE: callers relying on set behaviour (.add(), set
operators, == {...}) must be updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GridContainerPost set cType to "LIST", so grid containers were posted
with the list container type.
BREAKING CHANGE: grid containers are now sent with cType "GRID".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The TypeError message lacked its f prefix, so it printed the literal
"{type(item)} {item!r}" placeholders, and the bare except swallowed
any exception (including KeyboardInterrupt). Catch the ValueError that
urlparse raises and chain it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The "+ self._get_formated_error_message(...)" continuation sat on its own
line without parentheses, so it was evaluated as a separate, discarded
expression and msg was only "Export job failed: ".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Purely mechanical output of `ruff check --fix` followed by `ruff format`
over rspace_client, examples and .github/scripts. No manual edits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hand fixes for what `ruff check --fix` could not auto-fix, plus the type
annotations and small refactors needed for `mypy rspace_client` to pass:
PEP 604 unions, `X | None` for None-defaulted parameters, dict[str, Any]
annotations on self.data, and a ClientBase._get_api_url() stub.
Small behaviour changes worth noting:
- Container.capacity() raises NotImplementedError instead of returning
None.
- The EXACT grid move zips items and locations with strict=True.
- examples/tree_upload.py: a bare `exit` (a no-op) is now sys.exit(1).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New lint job runs ruff check, ruff format --check and mypy; unit tests
now depend on it and report coverage, failing below 55%.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ease.sh
Pushing a v* tag runs release.yml: unit tests, a tag/pyproject version
check, poetry build, then publish via PyPI Trusted Publishing (OIDC, no
API token). release.sh now takes only the new version, bumps it with
`poetry version`, formats with ruff instead of black, commits and tags,
and leaves publishing to CI. Dependabot groups weekly pip and GitHub
Actions updates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Newer RSpace servers treat the DataCite password as write-only and
return null for it from the settings update endpoint, so
test_update_datacite_settings_enabled failed with
`None != 'test_password'`. Drop that one assertion; the other fields
are still checked, and the test now passes against both older servers
that echo the password and newer ones that don't.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main added fsspec (runtime) and universal-pathlib (dev) to pyproject.toml
without updating the lock file, so `poetry check --lock` failed after the
rebase. Regenerated with `poetry lock`, which only adds fsspec,
pathlib-abc and universal-pathlib; no existing pins changed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ings
The four DataCite tests write dummy credentials and then tried to restore
the original settings from get_datacite_settings(). The API no longer
returns the stored password, so on a server with DataCite enabled the
restore passed password=None and raised ValueError, and on one with
saved-but-disabled credentials it left the dummies in their place.
Skip these tests when DataCite is enabled, or when a username other than
the tests' own dummy ones is saved, and always clean up by disabling
DataCite. CI and dev servers with no DataCite configuration still run
them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The FAILED export-job path lacks regression coverage, and the documented conda setup still creates an unsupported Python 3.7 environment instead of Python 3.10+.
Poetry 1.x generated the "Programming Language :: Python" classifiers
from the python constraint. Poetry 2 doesn't generate them when the
metadata is in the [project] table, so the 2.8.0 wheel would have had
none. That would also break the README's PyPI "Python versions" badge.
List 3.10 to 3.13 by hand to match the CI matrix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Regression tests are needed to verify filter isolation across filtered-then-unfiltered calls to both list_samples() and stream_samples(), preventing the shared-default bug from recurring unnoticed.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Add regression tests for filter isolation between calls
rspace_client/inv/inv.py:1425
The existing pagination tests do not check that filters are isolated between calls, so they would miss a return of the shared-default bug. Add an offline regression test that calls list_samples(sample_filter=SearchFilter(owned_by="alice")) and then list_samples() without pagination, asserting that the second request has neither ownedBy nor deletedItems. Cover the same filtered-then-unfiltered sequence for stream_samples() with default pagination.
The reason will be displayed to describe this comment to others. Learn more.
Review of the tooling modernisation. Locally on 3173991, all 349 unit tests pass, ruff check, ruff format --check and mypy rspace_client are clean, and coverage is 73.9%. I compared the ASTs before and after the style: commit 8c991e4 and found no behaviour changes, only import order, f-strings and unions. The FAILED-export fix matches the server: rspace-web's JobsApiHandlerImpl puts an ApiError with message and errors in result for FAILED jobs.
Inline comments below, roughly most important first. One more that sits outside the diff:
rspace_client/inv/inv.py:150 (AutoFit), missing f-prefix. The second half of the out-of-range message is a plain string:
+" must fit in dimensions ({total_columns}, {total_rows}"
so ByRow(5, 1, 3, 3, ss) prints the literal {total_columns}, {total_rows}. This is the same bug fixed in validators.py in f581c5b. The selected ruff rules don't catch it (RUF027 would, once it leaves preview).
- eln: abandoned or malformed export jobs raise ApiError and are logged
- inv: list/stream calls no longer write the filter into the caller's Pagination
- inv: Workbench.capacity() returns sys.maxsize; fix grid error message
- inv: extra_fields=None sends [] like the default
- tests: DataCite tests reuse their own leftover settings
- release: release.sh runs only on an up-to-date main; one Unreleased heading
- ci: release.yml checks the tag is on main and runs ruff/mypy; coverage 70%
- pre-commit: hooks use the Poetry-pinned ruff/mypy; Dependabot updates them separately
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Addressed @tilorspace's review in d51a87f: all inline comments plus the AutoFit f-prefix. Replies are on each thread.
Also from a follow-up review: export polling no longer crashes on errors: null or a missing percentComplete, and DEVELOPING.md describes the new release flow.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Providers with test usernames can bypass the guard even when enabled or targeting another server, allowing tests to overwrite credentials and leave them disabled without restoring their write-only passwords.
The DataCite integration tests overwrite the server's settings, and the
API never returns the stored password, so real settings cannot be
restored. The guard trusted the username alone, so a real account named
test_user, or one on a real server, would be reused and overwritten.
Reuse saved settings only when the username, server URL and repository
prefix all match what the tests write, or when the settings are blank
(disabled, no username or prefix, password ). Anything else, including
any stored secret, skips the tests. A leftover from an interrupted run
still matches, so recovery keeps working.
The logic moves to datacite_settings_conflict(), with offline tests for
blank, leftover, test username on a real server, other username, stored
secret without a username, and saved credentials while disabled.
test_get_datacite_settings now also asserts the password is None or ,
the response shape the guard relies on.
Verified against a local server: the five DataCite integration tests
pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR moves the project metadata to PEP 621 and Poetry 2, drops Python 3.9, adds ruff and mypy with a CI lint job, and adds a release workflow that publishes to PyPI when a
v*tag is pushed. Running ruff and mypy over the code turned up six bugs, and each fix has its own commit.Please review commit by commit. The
style:commit8c991e4is unedited ruff output, so you can skim or skip it.Breaking changes
requires-pythonis now>=3.10.Sample.wherep()returns alist, as documented, instead of aset..add()on the result, uses set operators on it, or compares it with== {...}GridContainerPostsendscType: "GRID"instead of"LIST".CHANGELOG.mdlists all three under "Potentially breaking".Changes
Packaging (
0358362,45e1535)[tool.poetry]to the standard PEP 621[project]table. Dev dependencies move to[dependency-groups], and the build backend ispoetry-core2.x.[project]table.poetry.lockis regenerated.mainaddedfsspecanduniversal-pathlibtopyproject.tomlwithout updating the lock file, sopoetry check --lockfailed after the rebase. The new lock addsfsspec,pathlib-abcanduniversal-pathliband changes no existing pins.Linting, formatting and typing (
05c9696,8c991e4,bc82e3a)pyproject.toml. ruff and mypy skipnotebook_sync.8c991e4is the output ofruff check --fixfollowed byruff format, with no manual edits.bc82e3afixes by hand what ruff could not fix automatically, and adds the annotations mypy needs to pass. These include PEP 604 unions,X | Nonefor parameters that default toNone,dict[str, Any]onself.data, and aClientBase._get_api_url()stub. It also changes three behaviours:Container.capacity()raisesNotImplementedErrorinstead of returningNone.strict=True, so a length mismatch raises an error instead of silently dropping the extra items.examples/tree_upload.py, a bareexitdid nothing. It is nowsys.exit(1).Bug fixes
dbd387fremoves shared mutable default arguments. Severalinvandelnmethods had defaults such asPagination(),tags=[],extra_fields=[],TopLevelTargetLocation(),item_ids=[]andtypesToInclude=[]. Python creates a default once and every call that omits the argument shares it, so aSearchFiltermerged into the defaultPaginationleaked into later calls. These parameters now default toNone, and each call builds a fresh value.f863a30makesSample.wherep()return a list, matching its annotation and docstring.598073dmakesGridContainerPostsendcType: "GRID".6cfdc59adds the missingselftoListContainer.is_list(). Without it, calling the method on an instance raisedTypeError.f581c5bfixes the URL validator. Its error message was missing thefprefix and printed the literal{...}placeholders. It also used a bareexcept, which caught everything includingKeyboardInterrupt. It now catches theValueErrorthaturlparseraises and chains it.8323263restores the server's error detail when an ELN export job fails. The+ self._get_formated_error_message(...)line had no surrounding parentheses, so Python treated it as a separate statement and threw the result away. The error read only "Export job failed: ".ad8ce4fadds a test for this.CI and release (
83036f8,6326a72)lintjob runsruff check,ruff format --checkandmypy rspace_client. The unit test job now waits for it.release.ymlworkflow runs when av*tag is pushed. It runs the unit tests, checks that the tag matches the version inpyproject.toml, builds the package and publishes it to PyPI. Publishing uses Trusted Publishing, which authenticates with OIDC, so no PyPI API token is stored anywhere.release.shnow takes only the new version number. It bumps the version withpoetry version, formats with ruff, then commits and tags. CI does the publishing.Tests (
1213f8e,32a8f3c,ad8ce4f)nullfor it. The DataCite settings test no longer asserts that the server echoes the password back.password=Noneand raisedValueError. On a server with saved but disabled credentials, it left the dummy values behind. The tests now skip when DataCite is enabled or when real credentials are saved, and they always disable DataCite when they finish. CI and dev servers with no DataCite configuration still run them.ad8ce4fadds a test for FAILED export jobs and moves the conda environment to Python 3.12.Docs (
3588123)CHANGELOG.md,DEVELOPING.mdand the comments inpyproject.toml.How to test
poetry install poetry run ruff check rspace_client examples poetry run ruff format --check rspace_client examples poetry run mypy rspace_client poetry run pytest -m "not integration" --cov=rspace_clientThe integration tests still need a live RSpace server. Run them with
poetry run pytest -m integrationand the usual environment variables.🤖 Generated with Claude Code