Repository navigation
Conversation
ModeSevenIndustrialSolutions
requested review from
a team
and
a balanced review from Copilot
October 2, 2026 10:41
The basedpyright hook ran in basic mode from pyrightconfig.json, downgraded most findings to warnings and exited 0 on them, and could not resolve pytest, so it reported 2 errors and 30 warnings on main. Move the configuration into [tool.basedpyright] in pyproject.toml and delete pyrightconfig.json and its REUSE annotation. Use standard mode for Python 3.10 (requires-python) on all platforms, scoped to src, test, scripts, typings and import_files.py. Drop the severity downgrades and the .venv lookup so the hook resolves imports from its own environment, which now installs hypothesis, mypy and pytest at their uv.lock versions. Run it with --warnings over the whole scope on every commit, and keep it in ci: skip because any additional_dependencies exceed the pre-commit.ci size limit. Fixes needed in standard mode: - Mirror the pure-Python modules meson installs into nss/ under typings/nss/ as symlinks, like the existing stubs, so the test import of nss.deprecations resolves. Exclude all the symlinks from analysis, since src/ is analysed and findings would appear twice. - Disable reportMissingModuleSource: the compiled extension cannot be installed in the hook environment, so every nss import finds its stub but no source by design. - test_util: import subprocess at module level. The local import left it unbound in the except clause, so any error other than FileNotFoundError surfaced as UnboundLocalError. - test_client_server: bind sock before the connect loop, reset it to None after each failed connect, and return None with a message when every address fails, as the function does for other connection failures, instead of carrying on with a closed socket. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
The ruff and ruff-format hooks matched only .py files under src, test and scripts, so the .pyi stubs for the compiled extension, which meson installs into the nss package, were never linted or formatted, and typings/nss/error.pyi lives outside those directories. Match .pyi files and add typings/ to both filters. The symlinked stubs in typings/nss/ are not passed (pre-commit skips symlinks), so each stub is checked once, via src/. ruff check finds nothing new; ruff format removes blank lines in error.pyi, per stub style. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
ModeSevenIndustrialSolutions
force-pushed
the
ci/enable-basedpyright
branch
from
October 2, 2026 11:25
087f8f4 to
e1d0a67
Compare
tykeal
approved these changes
Oct 6, 2026
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.

Summary
Brings basedpyright up to the organisation standard: configuration in
pyproject.toml, a hook that resolves every import and fails onwarnings, a scope that covers all real Python code, and zero findings.
Commits
CI(lint): Enable basedpyright: migratespyrightconfig.jsoninto[tool.basedpyright](and deletes it and itsREUSE.tomlannotation),configures the hook, and makes the fixes standard mode needs.
CI(lint): Lint the type stubs with ruff: the ruff andruff-format
files:filters matched only.pyundersrc|test|scripts, so the.pyistubs for the compiled extension,which meson installs into
nss/, were never linted.typings/nss/error.pyiwas outside those directories too. The filters now match
.pyiandtypings/. ruff check finds nothing new; ruff format removes 8blank lines in
error.pyi, following stub style. (This comes second sothat both commits leave
prek run --all-filesclean;mainalreadyfails basedpyright.)
Counts
main).pyiOn
main, the hook couldn't resolvepytest, and the 2 errors camefrom that. The new configuration's findings before the fixes:
reportMissingModuleSource, allnss.nss/nss.io/nss.ssl/nss.errorreportMissingImportsmypy.api(fixed:mypyis a declared test dependency, now a hook dependency)reportMissingImportsnss.deprecations(fixed: see below)reportPossiblyUnboundVariable(fixed: see below)Configuration
pythonVersion = "3.10": fromrequires-python = ">=3.10".pythonPlatform = "All",typeCheckingMode = "standard"(wasbasic).include = ["src", "test", "scripts", "typings", "import_files.py"],identical to the hook's arguments.
pytest'stestpaths = ["test"]isinside it.
doc/examples(legacy Py2-era examples, which tests onlysyntax-check) and
mutants(generated) stay out, as they already dofor ruff.
exclude: the sixtypings/nss/symlinks intosrc/. These arealready analysed through
src/, and scanning them again reported everyfinding twice. I checked that a defect is now reported once, and that
typings/nss/error.pyi(a real file) is still checked.stubPath = "typings"and thetestexecution environment withextraPaths = ["src"]are carried over, because tests putsrc/onsys.pathand importdeprecations,nss_contextandsecure_loggingby bare name.venvPath/venv = ".venv", so the hook resolves imports fromits own environment instead of whatever
.venva developer has.warningdowngrades ofreportMissingImports,reportGeneralTypeIssues,reportOptionalMemberAccessandreportOptionalSubscript, which are errors again.useLibraryCodeForTypes, thereportUnknown*/reportUntyped*/reportMissingTypeStubs/reportPrivateUsageoverrides, and thesrc/scriptsexecution environments.Hook
pass_filenames: false,always_run: true,stages: [pre-commit]andargs: [--warnings, src, test, scripts, typings, import_files.py].additional_dependencies:hypothesis==6.155.1,mypy==2.1.0andpytest==9.0.3. These are the only third-party modules the scanned codeimports, derived with
git grep -h -E '^(import|from) '. They're pinnedto
uv.lock, because the repository doesn't pin its other hookdependencies. All three ship
py.typed, so notypes-*packages areneeded.
Size and
ci: skipThe local hook environment measures 350 MiB with
du -sm(the barehook measures 274 MiB, so macOS overstates). pre-commit.ci measures the
bare hook at 248.7 MiB, against its 250 MiB per-hook limit, and any
additional_dependenciespush it over.basedpyrighttherefore stays inci: skip, now with a comment giving that reason. No workflow runsbasedpyright, so it's enforced developer-side only, through the local
hook.
The compiled extension
The repository already ships stubs for the compiled
nssmodule: thesrc/*.pyifiles are installed with the package, andtypings/nss/gives them thenss.*package layout through symlinks,plus a real
error.pyi. With those, basedpyright types every use ofthe compiled API. The tests import it as
import nss.nss as nss,from nss.error import NSPRError, and so on.reportMissingModuleSource = false. Eachnssimport finds its stub but not the compiled module, which needs a C
build against NSS/NSPR and can't be installed in a hook environment.
This warning is therefore expected and adds nothing, given that the
stubs supply the types. The suppression is documented inline.
reportMissingImportsstays enabled, and is an error.nss.deprecations.test_zzz_error_messages.pyimportsnss.deprecations. meson installsdeprecations,nss_contextandsecure_loggingintonss/alongside the extension, buttypings/nss/didn't mirror them. I added symlinks into
src/for all three,matching the existing stub symlinks, and updated the
typings/nss/__init__.pyidocstring. pre-commit,reuseand thepackaging all ignore
typings/.Code fixes
test/test_util.py:import subprocessmoves from inside thetryto module level. Previously, iffind_nss_toolraised anythingother than
FileNotFoundError, evaluatingexcept subprocess.TimeoutExpiredraised
UnboundLocalErrorand masked the real error. Passing runsbehave the same.
test/test_client_server.py: inclient(),sockwas possiblyunbound after the connect loop. It is now bound to
Nonebefore theloop and reset to
Noneafter each failed attempt is closed, soNonemeans no address connected. When every address fails, the function
now prints
client: could not connect to "<host>"and returnsNone.This matches how it already reports an unresolvable host or a lost
connection, and the caller's reply assertion then fails the test.
Previously it went on to
send()on the last, already closed socket.Successful connections
breakwith a live socket and behave exactlyas before. Only the failure path changes.
Validation
prek run --all-filesis clean after each commit.aislop-gate.sh upstream/main) reports clean.built, which the documented setup (
uv pip install -e ".[test]")can't do offline here. The local pytest hook skips without a
.venv.This PR's
build-test.yamlrun builds the extension and runs thesuite. The only test-code changes are the two above.
For review
test/run_tests(an extensionless legacy runner with no shebang) anddoc/get_apiare Python, but no Python hook covers them, before or afterthis PR. I left them out of scope as legacy and documentation tooling,
not source, scripts or tests that pytest runs.