Skip to content
Edit this page

Contributing

The contribution guide has the process (issues, pull requests, translations). This page is the developer's side of it.

Where a change usually goes

Change Files
A new threshold, URL or option src/config.py
A new weather value the request in services/open_meteo.py, the model in core/models.py, a level in core/levels.py, a card in ui/
A saved value the gschema, services/settings.py, ui/dialogs/preferences.py
An overview message or rule docs/overview-rules.md first, then core/overview/ and its test
A new file its layer's folder, plus meson.build, po/POTFILES, mousam.gresource.xml as needed

Easy-to-forget files: meson.build, po/POTFILES, the gschema, the appdata.

Code style

There is no formatter. When a file differs from these conventions, follow the file.

  • Python 3.12, nothing newer. Double quotes, 4 spaces, lines up to about 100 characters, no backslash continuations.
  • Relative imports inside src/. Standard library, then gi (with gi.require_version(...) first), then gi.repository, then local imports. No import *.
  • Type hints on new functions, kept simple. Prefer list[str] and str | None in new files.
  • API data goes into core/models.py and is read as attributes (cw.temperature_2m.data), not raw dicts.
  • No bare except:. Catch the specific exception and log it. A broad except Exception only at boundaries that must not crash (a worker thread's top level, RuleBook.run).
  • No mutable defaults, no print. Log with get_logger("<area>").
  • GLib callbacks return GLib.SOURCE_REMOVE / GLib.SOURCE_CONTINUE, never True / False.
  • Short and flat functions: return early, split a function that does two things.
  • Comments explain why (a thread, a GTK quirk, a leak avoided). Public classes and functions get a docstring. No commented-out code.
Thing Style
Modules, functions, variables snake_case
Classes PascalCase
Constants UPPER_SNAKE, in config.py or at the top of a module
Private leading _
Signal handlers _on_<source>_<what> (_on_store_status)
Idle and timeout callbacks what they do (_start_loading)

Name values with their unit when it matters: delay_seconds, sunrise_ts.

Strings and translations

  • Wrap every user-visible string in _(); use C_("context", "…") for ambiguous words ("Low", "Moderate") and ngettext for counts. Import per module: from gettext import gettext as _.
  • Strings with values use named placeholders and .format(): _("Material icons: {name}").format(name=…). Never _(f"…").
  • A string with placeholders gets a # Translators: comment right above it.
  • Translate whole sentences; never join translated pieces. Never translate Mousam.
  • Log messages are f-strings that say what happened and the value that matters.

Refactoring

Fix behaviour first, then extract logic, then move files, never mixed in one commit. A refactor changes no UI or behaviour. A file move is mechanical (git mv plus import updates). Don't reformat, rename or reorder code you aren't otherwise touching.

Git

  • Commit phase by phase, one logical change per commit.
  • Conventional Commits: type(scope): subject, with feat, fix, refactor, chore, style, docs (e.g. fix(render): …, chore(po): …).
  • Plan documents end in -plan.md, stay local and are gitignored.
  • .gitignore ignores test* everywhere except tests/.

Before opening a pull request

ruff check src tests
python3 -m compileall -q src
for t in tests/test_*.py; do python3 "$t"; done

Then build, install and run the app, and try your change in light and dark, metric and imperial. Include screenshots for visible changes.

Happy Coding ❤️