This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
pixi shell -e dev # activate dev environment (dev + docs features)
Python constraint: < 3.12 (pinned in pixi.toml).
pixi run -e dev lint # flake8 over tracked .py files
pixi run -e dev lint-imports # architectural import contracts (setup.cfg)
pixi run -e dev codespell # spelling
pixi run -e dev lint-security # bandit over mslib, configured in [tool.bandit] of pyproject.toml (CI job bandit in lint.yml)
pixi audit # known vulnerabilities in pixi.lock; needs the pixi-audit extension and PIXI_AUDIT_TOKEN, rules in [tool.pixi-audit] of pixi.toml (CI workflow audit.yml)
pixi run -e dev test-fast # api + plugins + utils + meta; no servers, fastest signal
pixi run -e dev test-msui # GUI suite (offscreen Qt)
pixi run -e dev test-mscolab # collaboration-server suite
MSCOLAB_TEST_POSTGRES_URL=postgresql://postgres:postgres@localhost:5432 pixi run -e dev test-mscolab # same on PostgreSQL (tests/database.py)
pixi run -e dev test-mswms # WMS-server suite
pixi run -e dev test # full suite (~13 min)
# one package with only its dependencies, as the conda recipe ships it (CI job test-packages)
pixi run -e msutils test-utils
pixi run -e msapi test-api
pixi run -e mswms test-mswms
pixi run -e mscolab test-mscolab # psycopg included, for MSCOLAB_TEST_POSTGRES_URL
pixi run -e msidp test-msidp
pixi run -e msui test-msui-without-servers # msui without the servers; tests marked "servers" run in dev
pixi run -e msui test-plugins
# single test file
pixi run -e dev env QT_QPA_PLATFORM=offscreen pytest tests/_test_msui/test_topview.py -v
# coverage XML
pixi run -e dev coverage xmlStart with ARCHITECTURE.md (package DAG, module index, invariants,
verification ladder). Each package under mslib/ has its own CLAUDE.md
card with layout, allowed imports, and how to verify changes there.
Dependency direction is enforced by import-linter (setup.cfg).
Single package mslib with four main subpackages:
- msui — PyQt5 desktop GUI (
msuientrypoint). Main window:mslib.msui.msui_mainwindow. - mscolab — Flask collaborative server (
mscolabentrypoint). Server:mslib.mscolab.server. DB models:mslib.mscolab.models. - mswms — WMS geospatial service (
mswmsentrypoint). Driver:mslib.mswms.mss_plot_driver. - utils — Shared utilities (coordinates, units, time, netCDF tools, the servers' basic auth); the client's config, keyring and Qt helpers are in
mslib/msui/utils/.
CLI entrypoints (pixi env): msui, mscolab, mswms, msidp, mssautoplot, mss.
Tests mirror the package structure under tests/ with subdirectories _test_api/, _test_mscolab/, _test_msui/, _test_mswms/, _test_plugins/, _test_utils/.
- Each package's suite runs with only that package installed: root
conftest.pyholds only what every suite needs (temp config dirs viatests.constants, loading the testmscolab_settingssomslib.mscolab.confnever binds the real database, the server-fork hooks), and the shared test modules (tests/fixtures.py,tests/utils.py,tests/server_setup.py) importmslib.*, Qt, Flask etc. only inside the functions that use them.mscolab_settings/mswms_settingsare generated bytests/server_setup.py, from the suite conftests and the server fixtures. tests/fixtures.pyprovides the server fixtures (mscolab_server,mswms_server,mscolab_app,mscolab_managers);tests/msui_fixtures.pythe client's (qtbot,fail_if_open_message_boxes_left, test keyring, msui config reset), loaded by the conftest.py of_test_msuiand_test_plugins.- Qt tests require
QT_QPA_PLATFORM=offscreenon headless machines. tests/test_meta.pychecks the tests themselves: noQApplication.processEvents()and noQTest.qWait((wait for the result instead, e.g.qtbot.wait_until(lambda: sip.isdeleted(view))), and the server icons stay copies of the msui icons. Run it (pixi run -e dev pytest -q tests/test_meta.py) for every change and every PR review that touchestests/or the icons; CI runs it intest-fast.- A test for a bug must fail without the fix: run it once against the old source and check that it fails for the reason of the bug. Do it in a separate worktree at the revision before the fix, so that the new tests stay in the run and uncommitted work in your checkout stays untouched (
git stashwould stash the new tests too,git checkout develop -- <files>overwrites uncommitted changes):git worktree add --detach ../mss-old $(git merge-base develop <branch or PR head>), copy the new or changed test files into it, run them there (pixi run -e dev pytest <test files>), thengit worktree remove --force ../mss-old(the copied tests are uncommitted changes there, without--forcegit keeps the worktree). Do the same in PR reviews for the PR's new tests. - bandit:
pixi run -e dev lint-securitymust report nothing, as the CI jobbanditinlint.ymlchecks (single files:pixi run -e dev bandit -c pyproject.toml <files>). Fix a real finding. Mark a false positive on the reported line as# nosec BXXX # reason: its test id, then the reason after a second#(bandit reads words right after the id as more test ids), never a bare# nosec. A hash that isn't used for security getsusedforsecurity=False. A marker on a value inside a literal over several lines (a dict or list) makes bandit warn for every other value of the literal, and a marker on an f-string for every other part of it; take the flagged value out into a single-line statement, and build SQL with"...".format(...)on a single string instead of an f-string. B101 (assert) is skipped until the decision for the upcoming release. - Keyring is mocked via
TestKeyringintests/msui_fixtures.py— no real keyring needed. - The client suites clean the msui config after every test via the
reset_configautouse fixture. - MSColab tests fork a real Flask-SocketIO server (multiprocessing fork, random port); the fork happens only in sessions that contain tests needing it.
- Flake8: max-line-length 120. Ignored: E124,E125,E402,W503,W504,A005. Excluded dirs:
mslib/msui/qt5/,mslib/mscolab/migrations/. - Codespell: exceptions in
codespell-ignored-lines.txt. Ignore list: PRES, degreeE, doubleClick, indexIn, socio-economic, EMAC, emac. - Qt UI files (
qt5/ui_*.py) are generated from.ui— do not edit by hand. - No CRLF in git. Whitespace at EOL in
tests/data/example.txtanddocs/samples/flight-tracks/example.txtis intentional.