Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

ahouseholder
Copy link
Contributor

This pull request includes a variety of updates across the test suite and the as_vocab package, 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:

  • Refactored the as_Activity class: the actor field now strictly uses as_ActorRef instead of a generic union type, improving type safety and clarity in the activity model. (vultron/as_vocab/base/objects/activities/base.py)
  • Updated activity classes (as_Travel, as_Arrive, as_Question) to use str for as_type instead of Literal, simplifying type usage and improving compatibility. (vultron/as_vocab/base/objects/activities/intransitive.py) [1] [2] [3]

Test Suite Improvements:

  • Consolidated and refactored CVSS pattern tests to use the new find_matches function, reducing duplication and improving maintainability. (test/case_states/test_cvss_patterns.py) [1] [2]
  • Improved actor activity tests by explicitly setting actor, object, and target fields, and switched to using model_validate_json for deserialization. Also updated assertions to use getattr for robustness. (test/test_as_vocab/test_actvitities/test_actor.py) [1] [2]

Type Annotation and Initialization Enhancements:

  • Added explicit type annotations in mock classes and state objects, and updated initialization of mock emit functions for clarity in messaging tests. (test/test_bt/test_behaviortree/test_messaging/test_cs_messages_inbound.py) [1] [2]
  • Improved type hints in the base model (as_Base) to use str | None for optional fields, aligning with modern Python typing standards. (vultron/as_vocab/base/base.py)

General Maintenance:

  • Updated copyright years to 2025 in multiple files.
  • Removed unused variables and streamlined example tests for clarity. (test/test_as_vocab/test_vocab_examples.py) [1] [2] [3] [4] [5] [6]
  • Added import for VOCABULARY in the package init file for easier access. (vultron/as_vocab/__init__.py)

Behavior Tree and Report Management Tests:

  • Refactored node factory tests to use proper function definitions instead of lambdas for improved docstring support. (test/test_bt/test_base/test_factory.py) [1] [2]
  • Updated report management condition tests to check node names for state inclusion rather than direct equality, improving test robustness. (test/test_bt/test_report_management/test_conditions.py)

@ahouseholder ahouseholder self-assigned this Sep 26, 2025
@ahouseholder ahouseholder added the tech/backend Changes to modules, libraries, etc. label Sep 26, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 | None instead of Optional[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_idid, as_objectobject)
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_matches function
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 Literal types with flexible str types 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:
Copy link

Copilot AI Sep 26, 2025

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.

Copilot uses AI. Check for mistakes.


@ensure_valid_state
def embargo_viability(state: str) -> EmbargoViability:
def embargo_viability(state: str) -> list[EmbargoViability]:
Copy link

Copilot AI Sep 26, 2025

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.

Copilot uses AI. Check for mistakes.

def serialize_datetime(self, value: datetime | None) -> str | None:
if value is None:
return None
return value
Copy link

Copilot AI Sep 26, 2025

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.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tech/backend Changes to modules, libraries, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant