Skip to content

Cast Any returns to eliminate no-any-return errors in strict mypy#931

Merged
johanlundberg merged 8 commits intomainfrom
ylle-cast-for-typing-issues
Apr 14, 2026
Merged

Cast Any returns to eliminate no-any-return errors in strict mypy#931
johanlundberg merged 8 commits intomainfrom
ylle-cast-for-typing-issues

Conversation

@helylle
Copy link
Copy Markdown
Contributor

@helylle helylle commented Apr 13, 2026

Cast Any returns to eliminate no-any-return errors in strict mypy

Summary

  • Add cast() at third-party library boundaries to eliminate all 75 [no-any-return] strict mypy errors
  • Fix real type bug: vccs/client _execute_request_response declared -> str but urlopen().read() returns bytes
  • Remove dead isinstance branch in userdb/user.py _parse_profiles (unreachable code, now matches sibling parsers)

Sources of Any

All casts are at boundaries where untyped third-party libraries return Any:

Source Files Errors fixed
Celery AsyncResult.get() via celery-types stub limitation relay classes, worker tasks 13
@MarshalWith decorator returning Callable[..., Any] (inter-view calls) group_management, jsconfig 10
response.json() (requests/hammock) ekopost, scimapi tests 8
json.loads() test helpers, redis_session 7
Untyped libs (yubihsm, jwcrypto, pwgen, smscom, ndnkdf, suds) vccs, common, workers 10
WSGI Callable[..., Any] middleware, debug 4
Starlette state (Any) context_request (2 files) 2
pysaml2 untyped returns authn/utils, satosa 3
MongoDB/Neo4j untyped returns graphdb, testing, vccs/server 5
Other (decorator wrappers, fido_mds) idp/decorators, test_webauthn 5

Strict mypy error reduction

  • [no-any-return]: 75 → 0
  • Total: 98 → 25 (remaining: 16 [misc] SATOSA stubs, 7 [type-arg] variance, 2 other)

@sonarqubecloud
Copy link
Copy Markdown

@helylle helylle marked this pull request as ready for review April 14, 2026 06:41
@johanlundberg johanlundberg merged commit 57df026 into main Apr 14, 2026
12 checks passed
@johanlundberg johanlundberg deleted the ylle-cast-for-typing-issues branch April 14, 2026 09:12
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.

2 participants