Repository navigation
DOC: document None return for late-binding transformers - #1637
Conversation
Transformer.to_wkt()/to_json()/to_json_dict() silently return None (or raise TypeError from to_json_dict) when the transformer was built via from_crs() without an area_of_interest, because it represents multiple candidate operations rather than a single one with a defined string representation. Confirmed by maintainers in #1549 as expected but undocumented behavior. Document the cause and the area_of_interest / from_pipeline() workaround on all three methods. Fixes #1549
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1637 +/- ##
==========================================
- Coverage 95.85% 95.84% -0.01%
==========================================
Files 20 20
Lines 1880 1879 -1
==========================================
- Hits 1802 1801 -1
Misses 78 78 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@shaikn6 mind updating the function type hint for the return from |
|
Done — (The one failing Conda macOS job looks like CI infra noise — this branch is docs/annotations only and an earlier run on the same commit range passed.) |
|
Hi @snowman2, just checking in — the |
|
Thanks @shaikn6 👍 |
What
Document why
Transformer.to_wkt(),to_json(), andto_json_dict()can returnNone/ raiseTypeError.Why / evidence
Transformer.from_crs()without anarea_of_interestbuilds a "late-binding" transformer that may represent several candidate coordinate operations rather than one, so there is no single WKT/JSON string to return. The docstrings promised astr/dictunconditionally, which surprised users (#1549) --to_json()returnsNone, andto_json_dict()then raisesTypeError: the JSON object must be str, bytes or bytearray, not NoneTypebecause it feeds thatNoneintojson.loads. Maintainersphaarnes/rouaultconfirmed this is expected PROJ behavior andsnowman2agreed it should be documented, but no doc PR followed.Change
Added a
Notessection to each of the three methods' docstrings inpyproj/transformer.pyexplaining the late-binding cause and the fix (passarea_of_interest, or useTransformer.from_pipeline(), to get a transformer for a single concrete operation).Verified
Reproduced with pyproj 3.8.0 in a clean venv:
Confirmed the documented workaround resolves it:
python3 -c "import ast; ast.parse(open('pyproj/transformer.py').read())"-- syntax OK. Docs-only change, no code path modified.Fixes #1549