- 
                Notifications
    You must be signed in to change notification settings 
- Fork 4
Code linting #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Code linting #245
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request implements comprehensive linting improvements across the codebase, focusing on type safety, code modernization, and consistency enhancements. The changes modernize Python typing patterns, improve error handling, and streamline various implementation details.
- Updated type annotations throughout to use modern Python typing syntax (e.g., str | Noneinstead ofOptional[str])
- Refactored Activity Streams vocabulary to use generic string types instead of restrictive literals for better flexibility
- Enhanced type safety with proper generic typing and improved function signatures
Reviewed Changes
Copilot reviewed 59 out of 60 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description | 
|---|---|
| vultron/scripts/vocab_examples.py | Updated field names from as_*to standard names (as_id→id,as_object→object) | 
| vultron/scripts/ontology2md.py | Added type annotations and improved error handling | 
| vultron/case_states/validations.py | Enhanced decorator typing with proper generic bounds and wraps usage | 
| vultron/case_states/type_hints.py | New file providing centralized type hints for case state functions | 
| vultron/case_states/states.py | Reorganized function definitions and added comprehensive type annotations | 
| vultron/case_states/patterns/cvss31.py | Consolidated CVSS pattern matching into reusable find_matchesfunction | 
| vultron/case_states/patterns/base.py | Added proper type annotations for pattern compilation functions | 
| vultron/bt/base/factory.py | Improved type safety for node factory functions with proper generic handling | 
| vultron/as_vocab/base/objects/activities/*.py | Replaced restrictive Literaltypes with flexiblestrtypes for activity classes | 
| vultron/as_vocab/base/base.py | Modernized type hints and improved field definitions | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|  | ||
|  | ||
| def embargo_event(days: int = 90) -> as_Event: | ||
| def embargo_event(days: int = 90) -> EmbargoEvent: | 
    
      
    
      Copilot
AI
    
    
    
      Sep 26, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function return type annotation changed from as_Event to EmbargoEvent, but EmbargoEvent is not imported. This will cause a NameError when the function is defined.
|  | ||
| @ensure_valid_state | ||
| def embargo_viability(state: str) -> EmbargoViability: | ||
| def embargo_viability(state: str) -> list[EmbargoViability]: | 
    
      
    
      Copilot
AI
    
    
    
      Sep 26, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function return type annotation indicates it returns list[EmbargoViability], but the implementation uses list[EnumTuple] for results and extends with viability which contains tuples. This type mismatch will cause runtime issues.
| def serialize_datetime(self, value: datetime | None) -> str | None: | ||
| if value is None: | ||
| return None | ||
| return value | 
    
      
    
      Copilot
AI
    
    
    
      Sep 26, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The serialize_datetime method should return None for None values, but now returns the value as-is. This could cause JSON serialization issues when the value is None.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
This pull request includes a variety of updates across the test suite and the
as_vocabpackage, focusing on refactoring for clarity, updating copyright years, improving type annotations, and simplifying test logic. The most important changes are grouped below.Refactoring and API Consistency:
as_Activityclass: theactorfield now strictly usesas_ActorRefinstead of a generic union type, improving type safety and clarity in the activity model. (vultron/as_vocab/base/objects/activities/base.py)as_Travel,as_Arrive,as_Question) to usestrforas_typeinstead ofLiteral, simplifying type usage and improving compatibility. (vultron/as_vocab/base/objects/activities/intransitive.py) [1] [2] [3]Test Suite Improvements:
find_matchesfunction, reducing duplication and improving maintainability. (test/case_states/test_cvss_patterns.py) [1] [2]actor,object, andtargetfields, and switched to usingmodel_validate_jsonfor deserialization. Also updated assertions to usegetattrfor robustness. (test/test_as_vocab/test_actvitities/test_actor.py) [1] [2]Type Annotation and Initialization Enhancements:
test/test_bt/test_behaviortree/test_messaging/test_cs_messages_inbound.py) [1] [2]as_Base) to usestr | Nonefor optional fields, aligning with modern Python typing standards. (vultron/as_vocab/base/base.py)General Maintenance:
test/test_as_vocab/test_vocab_examples.py) [1] [2] [3] [4] [5] [6]VOCABULARYin the package init file for easier access. (vultron/as_vocab/__init__.py)Behavior Tree and Report Management Tests:
test/test_bt/test_base/test_factory.py) [1] [2]test/test_bt/test_report_management/test_conditions.py)