Conversation
… classes Implement comprehensive type hints and defensive programming patterns across config parser, packet config, telemetry, and system modules to improve type safety and error handling. BREAKING CHANGE: SystemMeta properties now raise RuntimeError instead of returning None when System instance is not initialized. Code accessing System.telemetry, System.commands, etc. before System.instance() is called will now receive explicit errors. Changes: - Add comprehensive type hints to Telemetry class with TYPE_CHECKING pattern to avoid circular imports - Add explanatory comments for TYPE_CHECKING blocks - Implement SystemMeta property setters for all singleton attributes (targets, packet_config, commands, telemetry, limits) - Change SystemMeta property getters to raise RuntimeError with clear message when instance_obj is None instead of silently returning None/empty dict - Add defensive None checks in ConfigParser methods (verify_num_parameters, verify_parameter_naming, parse_errors) - Add defensive None checks in PacketConfig for current_packet and current_item access across multiple keyword handlers - Implement XTCE file detection with NotImplementedError and clear error message - Fix type narrowing in parse_errors() using isinstance() instead of issubclass() - Add local typed variable pattern (line_buffer: str) to resolve Optional string concatenation issues - Add type: ignore[has-type] comments to suppress ambiguous generic instance variable access warnings - Fix test_commands.py setUp to properly initialize System instance Impact: - 246 tests passing (up from 199 originally failing) - 48 originally failing tests now fixed - 47 test_commands.py tests now passing - Only 3 remaining failures are pre-existing jsonpath_ng dependency issues - Improved error messages provide clearer debugging information - Type checkers (Pylance/mypy) now have complete type information Files modified: - openc3/python/openc3/config/config_parser.py - openc3/python/openc3/packets/packet_config.py - openc3/python/openc3/packets/telemetry.py - openc3/python/openc3/packets/parsers/xtce_converter.py - openc3/python/openc3/system/system.py - openc3/python/test/packets/test_packet_config.py - openc3/python/test/packets/test_commands.py
…g-systemtelemetry-and-systemcommands-methods-in-python
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2569 +/- ##
==========================================
- Coverage 79.18% 79.12% -0.06%
==========================================
Files 662 663 +1
Lines 51305 51800 +495
Branches 735 735
==========================================
+ Hits 40626 40988 +362
- Misses 10599 10732 +133
Partials 80 80
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: aikido-pr-checks[bot] <169896070+aikido-pr-checks[bot]@users.noreply.github.com>
Co-authored-by: aikido-pr-checks[bot] <169896070+aikido-pr-checks[bot]@users.noreply.github.com>
jmthomas
approved these changes
Nov 26, 2025
Member
jmthomas
left a comment
There was a problem hiding this comment.
Was there a specific use-case for this code? Why did you add this?
Contributor
Author
Ticket looked like and opportunity to explore the codebase more. |
Member
|
Use case was python based conversions for a customer. |
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.
Python Methods Added
This branch implements missing Python methods that were already present in the Ruby codebase.
System class (
openc3/python/openc3/system/system.py)Added class-level properties (via metaclass) to access singleton instance attributes:
System.targets(property getter/setter at lines 42-58)instance_attr_reader :targetsatopenc3/lib/openc3/system/system.rb:39System.packet_config(property getter/setter at lines 61-77)instance_attr_reader :packet_configatopenc3/lib/openc3/system/system.rb:42System.commands(property getter/setter at lines 80-96)instance_attr_reader :commandsatopenc3/lib/openc3/system/system.rb:45System.telemetry(property getter/setter at lines 99-115)instance_attr_reader :telemetryatopenc3/lib/openc3/system/system.rb:48System.limits(property getter/setter at lines 118-134)instance_attr_reader :limitsatopenc3/lib/openc3/system/system.rb:51Telemetry class (
openc3/python/openc3/packets/telemetry.py)newest_packet(target_name, item_name)at line 92def newest_packetatopenc3/lib/openc3/packets/telemetry.rb:227packet_and_item(target_name, packet_name, item_name)at line 115def packet_and_itematopenc3/lib/openc3/packets/telemetry.rb:94value(target_name, packet_name, item_name, value_type)at line 134def valueatopenc3/lib/openc3/packets/telemetry.rb:115values_and_limits_states(item_array, value_types)at line 149def values_and_limits_statesatopenc3/lib/openc3/packets/telemetry.rb:133PacketConfig class (
openc3/python/openc3/packets/packet_config.py)to_config(output_dir)at line 293def to_configatopenc3/lib/openc3/packets/packet_config.rb:276to_xtce(output_dir)at line 375def to_xtceatopenc3/lib/openc3/packets/packet_config.rb:331Typing
Added type hints to the methods.
None checking
Added a bunch of checks for None to remove the
PyLanceerrors.Ruff Checks
https://docs.astral.sh/ruff/rules/if-else-block-instead-of-if-exp/
Closes #2532