Skip to content

Update to pass under the latest flake8-bugbear - #1432

Merged
sirosen merged 2 commits into
globus:mainfrom
sirosen:pass-latest-bugbear
Sep 15, 2026
Merged

sirosen merged 2 commits into
globus:mainfrom
sirosen:pass-latest-bugbear

Conversation

@sirosen

@sirosen sirosen commented Sep 14, 2026

Copy link
Copy Markdown
Member

Primarily, flake8-bugbear flags several of our exceptions as being
unsafe to stringify, copy, or pickle because they don't pass args to
super() in the mandated way. (This is the new B042 rule.)

In order to pass, most of these cases are simple to update to define and
test explicit str() and copy.copy() calls. Copy is a simpler
operation than pickling and exercises the same reducer. For the target
error types, defining custom __reduce__ methods is sufficient.

For GlobusAPIError, because it's so key to SDK interfaces, no action
is taken for now, other than the addition of a TODO comment.

New unit tests exercise str and copy.copy on all of the updated errors.

@codspeed

This comment was marked as off-topic.

Primarily, flake8-bugbear flags several of our exceptions as being
unsafe to stringify, copy, or pickle because they don't pass args to
`super()` in the mandated way. (This is the new B042 rule.)

In order to pass, most of these cases are simple to update to define and
test explicit `str()` and `copy.copy()` calls. Copy is a simpler
operation than pickling and exercises the same reducer. For the target
error types, defining custom `__reduce__` methods is sufficient.

For `GlobusAPIError`, because it's so key to SDK interfaces, no action
is taken for now, other than the addition of a TODO comment.

New unit tests exercise str and copy.copy on all of the updated errors.
@sirosen
sirosen force-pushed the pass-latest-bugbear branch from 4301466 to 1ec5c3a Compare September 14, 2026 19:02
@sirosen

sirosen commented Sep 14, 2026

Copy link
Copy Markdown
Member Author

I believe the codspeed "improvement" is not real, and is an artifact of some other change (e.g., new machine image from GitHub). I can't see any way that making this change would improve performance of that part of the code.

My current working theory is that changing the imports in the exception modules is enough to rejigger the layout of some data in memory and this benchmark is so hypersensitive that it detects the difference. That might point at a potential improvement to benchmarks for the future, but I'm not sure what exactly we should be doing to make this more stable.

Comment thread tests/unit/errors/test_error_copy.py Outdated
Comment thread tests/unit/errors/test_error_copy.py
Co-authored-by: Kurt McKee <contactme@kurtmckee.org>
@sirosen
sirosen merged commit 92f0df5 into globus:main Sep 15, 2026
11 checks passed
@sirosen
sirosen deleted the pass-latest-bugbear branch September 15, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-news-is-good-news This change does not require a news file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants