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 pyproj4#1549 as expected but undocumented behavior. Document the cause and the area_of_interest / from_pipeline() workaround on all three methods. Fixes pyproj4#1549
snowman2
reviewed
Sep 14, 2026
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:
|
Member
|
@shaikn6 mind updating the function type hint for the return from |
Author
|
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.) |
This branch has not been deployed
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.
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