Add strict typing across package, enable mypy in pre-commit#19
Merged
Conversation
…-win type hints - Add helpers/rosdep_wrapper.py as the single typed boundary around rosdep2; lazy imports preserve existing test patches and sys.modules swaps - Route rosdep_validator and verify_rosdep_mapping through the wrapper - Add XmlElement TYPE_CHECKING alias in package_types.py for future lxml typing - Annotate remaining functions in cmake_parsers, find_launch_dependencies, workspace, and logger so those modules are 100% typed
…oint - Add type hints to all functions in validation_steps, pkg_xml_formatter, rosdep_validator, package_xml_validator, and verify_rosdep_mapping - Use XmlElement alias (now a proper TypeAlias) consistently for lxml elements; isolate untyped argcomplete import behind a single ignore - Widen LaunchDependencyStep.package_name to str | None to match formatter.get_package_name()'s return type - Initialize PackageXmlValidator.rosdep_validator to None up-front and narrow with explicit checks before passing to dependent steps
- Add [tool.mypy] config + dev extras in pyproject.toml (strict; per-module ignore_missing_imports for rosdep2, argcomplete, regex, helpers.*) - Add mypy hook to .pre-commit-config.yaml (CI picks it up automatically) - Fix latent bugs surfaced by mypy: None-text sorted() crashes and reused-name type drift in pkg_xml_formatter; shadowed except-var in verify_rosdep_mapping; export narrowing in BuildTypeExportStep - Fix verify-rosdep-map hook to invoke as a module so the new rosdep_wrapper relative import resolves
Bring per-package dependency exception support (#18) into the typing branch. Conflicts touched the two files where the typing pass overlapped with the new 'exceptions' parameter
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Summary
package_xml_validationpackage (validation pipeline, formatter, rosdep validator, helpers, entrypoint) and introduce anXmlElementTypeAliasfor lxml elements.rosdep2dependency behind a newhelpers/rosdep_wrapper.pyso the rest of the codebase has a single, typed boundary. Lazy imports inside the wrapper preserve existing test patches andsys.modulesswaps.pyproject.tomland add a mypy hook in.pre-commit-config.yaml. Per-moduleignore_missing_importsis scoped torosdep2.*,argcomplete.*,regex, and thehelpers.*script-mode fallback — so a missing stub for any other dep still surfaces as a real error.None-textsorted()crashes and reused-name type drift inpkg_xml_formatter.pyverify_rosdep_mapping.pyBuildTypeExportStep(validation_steps.py)LaunchDependencyStep.package_nametostr | Noneto matchformatter.get_package_name()'s return typePackageXmlValidator.rosdep_validatortoNoneup-front and narrow with explicit checks before passing to dependent stepsverify-rosdep-maphook to invokepython3 -m package_xml_validation.helpers.verify_rosdep_mappingso the new package-relative import inrosdep_wrapperresolves.devoptional-dependencies group (mypy,types-PyYAML,lxml-stubs) for local setup.