Add --tree flag for FamilySearch Group tree selection - #82
Conversation
Adds a -T/--tree CLI argument and corresponding Session parameter that
activates a specific FamilySearch user tree at login time, by POSTing to
/platform/trees/current. Without the flag, behaviour is unchanged: the
main shared Family Tree ("GLOBAL") is used.
Error handling follows existing project conventions: HTTP 400 (invalid
tree ID) exits immediately with a user-facing message; HTTP 429 backs off
and retries; other transient errors log and retry. The default value
"GLOBAL" is defined as DEFAULT_TREE in session.py and imported by the
CLI, making it the single source of truth.
Also adds uv tooling support (uv.lock, [tool.uv] package = true in
pyproject.toml). Using uv is optional — pip/other tools continue to work
as before. The package = true flag is required for uv to install the CLI
entry points (getmyancestors, mergemyancestors, fstogedcom).
Bumps requires-python from >=3.7 to >=3.9. The bump was required by
uv's dependency resolver and reflects reality: 3.7 has been end-of-life
since June 2023, and 3.9 itself reached end-of-life in October 2025.
Users on a supported Python release are unaffected.
|
Hi, is this PR ready for review? One thing I noticed: after the |
|
Yes, this is ready for review. Indeed, the tree ID is not used anywhere. This is due to an (IMHO strange) design decision by FamilySearch for their API that it's stateful, i.e. once you Because I've also successfully used |
PR: Add
--treeflag for FamilySearch Group tree selectionSummary
-T/--treeCLI argument to target a specific FamilySearch Group tree instead of the default main Family Treerequires-pythonfrom>=3.7to>=3.9The feature
FamilySearch exposes two distinct tree systems: the single shared main Family Tree, and privately-owned user trees, called "Group trees" on the UI (
/platform/trees/…). This project previously had no way to target a user tree — the tree selection call had to be manually patched in.The new flag activates a user tree by POSTing to
/platform/trees/currentimmediately after login, scoping all subsequent API calls to that tree. Omitting the flag leaves behaviour unchanged.Error handling
Note: 400 is also returned by the API for an invalid bearer token, but since
_set_treeis only called after a successfullogin(), a valid token is guaranteed at that point.Implementation notes
DEFAULT_TREE = "GLOBAL"is defined as a module-level constant insession.pyalongside the existingDEFAULT_CLIENT_IDandDEFAULT_REDIRECT_URIconstants. The CLI imports it directly, making it the single source of truth for the default value and the--helpdisplay.if self._tree and self._tree != DEFAULT_TREEin__init__ensures no API call is made when the default is used.uv support
Adds
uv.lockand[tool.uv] package = truetopyproject.toml. Thepackage = trueflag is required for uv to install the CLI entry points (getmyancestors,mergemyancestors,fstogedcom); without it uv treats the project as a non-package workspace member and skips installation.Using uv is entirely optional. pip and other tools continue to work as before.
Python version bump (3.7 → 3.9)
The bump was required by uv's dependency resolver. It reflects reality:
Users on any currently supported Python release (3.10+) are unaffected.
Test plan
getmyancestors … -T <valid-tree-id>— downloads from the specified user treegetmyancestors … -T <invalid-id>— exits with a clear error message, no tracebackgetmyancestors …(no-T) — behaviour identical to before this changeuv run getmyancestors— CLI entry point installs and runs correctly