Repository navigation
Declare the public top-level API in __all__ so type checkers export it - #1485
Closed
1915rising wants to merge 1 commit into
Closed
1915rising wants to merge 1 commit into
1915rising wants to merge 1 commit into
Conversation
Owner
|
mypy works fine ... |
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.
Fixes #1484.
Because ezdxf ships a py.typed marker, pyright/Pylance follow the typing spec rule that a name imported into a package init is private unless it is listed in all or re-exported with a redundant alias. None of the top-level names were declared, so the README example itself failed checking: "new" is not exported from module "ezdxf" (reportPrivateImportUsage) — and the same applied to readfile, read, options, version, the DXF exception classes, the DXF version constants and every other re-export.
Reproduction (pyright, reportPrivateImportUsage=true, against a 6-line script using ezdxf.new, ezdxf.readfile, ezdxf.options, ezdxf.version, ezdxf.DXFError, ezdxf.InsertUnits): 6 reportPrivateImportUsage errors before, 0 after. The code always ran correctly; this is a declaration-only change, no runtime behaviour changes (star-import and ezdxf.new() verified unchanged).
Fix: add an explicit all to ezdxf/init.py listing all 53 public names — every name the module imports for re-export plus its public module-level constants and print_config.
Tests: new tests/test_10_issues/test_issue_1484_public_api_exports.py (3 tests) asserts every name in all exists, that every module-level from-import in init.py is exported (guards future re-exports), and that the documented names from the issue are exported. The new tests fail on the unmodified init (3 failed) and pass with the fix. tests/test_10_issues: 31 passed after. Broader spot check (test_533_shapefiles + test_00_dxf_low_level_structs): 576 passed.