Repository navigation
chore: resolve all pyright diagnostics and add a pyright CI job (#95) - #109
Merged
Merged
Conversation
pyright 1.1.414 reports 0 errors against the repo (55 findings at HEAD, up from the 23 in the issue - PRs #96-#108 added more). Source fixes: None-guards on Optional user_id/token values, isinstance feature-detect for the 401 hook per the JsonClient contract, dict[str, object] payload typing, a Retry-After None-check, and removal of the dead pre-#857 campus.model fallback import. Test fixes: MagicMock casts where runtime swaps in mocks, None-narrowing asserts, one parameter rename, and rule-scoped pyright ignores on deliberate-negative pins. Adds pyright (^1.1.400) as a dev dependency and a pyright job to python-tests.yml following the nyxchange pattern. Fixes #95
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Resolves every pyright diagnostic (#95) and adds a pyright job to
.github/workflows/python-tests.ymlfollowing the nyxchange-timetable-v2 pattern (pyright as a dev dependency,poetry run pyright).At HEAD of main, pyright 1.1.414 reported 55 errors (the issue counted 23; PRs #96–#108 added code since). After this PR: 0 errors, 0 warnings, and all 291 unit tests pass.
Source fixes (
campus_python/)LoginSession.user_idisUserID | None; the credentials lookups in_get_token_from_sessionand the auth token getter now raiseAuthenticationErrorwhen it is None instead of indexing with a possible None.push_contextskips the users-route fallback (and the cache put) when there is neither an embedded user nor a user id.with_user_sessionnow installs the unauthorized hook viaisinstance(client, CampusRequest)— matching the documented JsonClient contract ("callers must feature-detect") instead of assuming every client has the optional capability.env.get(...) or ""afterenv.require("AUDIT_API_KEY")(require guarantees presence but returns None).audit/ratelimit.py): explicit None-check instead of relying onfloat(None)raising TypeError.assignments.new()payload annotateddict[str, object].HttpHeaderfromcampus.modelinjson_client— the lock now resolves campus-suite past the webauth move, so the fallback branch can never run and no longer type-checks.Test fixes (
tests/unit/)MagicMock/castwhere runtime swaps real objects for mocks (_session,client.post,_usersaccessed through stored mock references instead of the typed properties).assertIsNotNone(pyright does not narrow through unittest assertions).fake_send(prepared=…)renamed torequestto match theSession.sendsignature.# pyright: ignore[reportCallIssue]/[reportMissingImports]on deliberate-negative pins (constructor-must-reject kwargs, the sys.path-shimmederrorsimport).Verification
poetry run pyright— 0 errors, 0 warnings (pyright 1.1.414 via^1.1.400dev dep).poetry run pytest— 291 passed.Fixes #95