Skip to content

Conversation

@Intuity
Copy link
Owner

@Intuity Intuity commented Nov 13, 2025

This PR introduces a number of changes and improvements to the library from real-world use:

  • Packtype grammar (i.e. .pt files) updates:
    • New variants keyword, which can be used for feature-flagging or allowing different activities to lag the bleeding edge;
    • New 'normative points' syntax, which can be used for declaring key items in an architectural specification that can then be used as anchors in prose, models, or coverage;
  • PackedAssembly gains a recursive tree printer, which can display complex structures allowing for easier reading of constituent fields;
  • PackedArray now extends from Numeric which allows it to be used in comparisons, it also gains a __str__ method to allow it to be printed with ease;
  • Minor optimisations to BitVector which yield a small performance improvement;
  • Extensions to a range of utility methods to better handle core types, add support for copying instances, diffing two types, and more;
  • Moves the minimum Python version forward to 3.12 - this allows for a number of useful type hinting behaviours.

@Intuity Intuity requested a review from Copilot November 13, 2025 09:46
Copy link

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 PR introduces version 3.1.0 with several enhancements and improvements to the packtype library. The main additions include a new variants feature for conditional compilation, a copy utility function for packtype instances, a diff utility for comparing packtype objects, and improved string representations with tree-style formatting. Additional improvements include better test coverage, documentation updates, and bug fixes.

Key changes:

  • Added variants feature to support conditional definitions in packtype grammar
  • Implemented utility functions for copying and comparing packtype instances
  • Enhanced string representation with tree-style formatting for nested structures
  • Added normative points support for marking priority levels

Reviewed Changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vscode/packtype/syntaxes/packtype.tmLanguage.json Added syntax highlighting for variants and default keywords
tests/utils/test_utils_basic.py Added comprehensive tests for new diff, diff_table, copy utilities and enhanced get_width tests
tests/svg/test_struct_svg.py Updated to use sys.executable instead of hardcoded python3
tests/pysyntax/test_union.py Updated test assertions to match new tree-style string formatting
tests/pysyntax/test_struct.py Updated test assertions and added test for max_depth parameter in tree printing
tests/pysyntax/test_array.py Added tests for array comparison and string representation
tests/integration/test_sv.py Updated to use sys.executable instead of hardcoded python3
tests/grammar/test_variant.py Added comprehensive tests for the new variants feature
tests/grammar/test_union.py Added test for copying union instances
tests/grammar/test_struct.py Added test for copying struct instances
tests/grammar/test_scalar.py Added test for copying scalar instances
tests/grammar/test_normative.py Added tests for the new normative points feature
tests/grammar/test_enum.py Added test for copying enum instances
tests/grammar/test_descriptions.py Fixed import statement formatting
pyproject.toml Updated version to 3.1.0 and added tabulate dependency
packtype/utils/union.py Refactored normalization function with improved documentation and type checking
packtype/utils/struct.py Refactored normalization function with improved documentation and type checking
packtype/utils/package.py Added get_all_types utility and fixed ScalarType import
packtype/utils/enum.py Added is_enum utility and improved normalization function
packtype/utils/basic.py Added copy, diff, and diff_table utilities; enhanced get_name for arrays
packtype/utils/init.py Exported new utility functions
packtype/types/package.py Added support for normative points and refactored filtering methods
packtype/types/normative.py Added new NormativePoint class for priority marking
packtype/types/bitvector.py Fixed typo and optimized window width computation
packtype/types/base.py Added copy and deepcopy guards to enforce using utils.copy
packtype/types/assembly.py Refactored string representation to use tree-style formatting with depth control
packtype/types/array.py Made PackedArray inherit from Numeric and added string representation
packtype/start.py Added variant support to CLI commands and updated type hints
packtype/grammar/transformer.py Added variant transformation logic and TransformerError class
packtype/grammar/packtype.lark Added grammar rules for variants and normative points
packtype/grammar/grammar.py Added variant flattening logic in parse functions
packtype/grammar/examples/package_b.pt Removed example file
packtype/grammar/examples/package_a.pt Removed example file
packtype/grammar/declarations.py Added variant and normative declaration classes
mkdocs.yml Added variants documentation to navigation
examples/variants/test.sh Added test script for variants example
examples/variants/spec.pt Added variants example specification
docs/syntax/variants.md Added comprehensive variants documentation
docs/syntax/union.md Updated package naming in examples from MyPackage to ThePackage
docs/syntax/struct.md Updated package naming in examples from MyPackage to ThePackage
docs/syntax/scalar.md Updated package naming in examples from MyPackage to ThePackage
docs/syntax/package.md Updated package naming in examples from MyPackage to ThePackage
docs/syntax/instance.md Updated package naming in examples from MyPackage to ThePackage
docs/syntax/enum.md Updated package naming in examples from MyPackage to ThePackage
docs/syntax/docstrings.md Updated package naming in examples from MyPackage to ThePackage
docs/syntax/constant.md Updated package naming in examples from MyPackage to ThePackage
Comments suppressed due to low confidence (2)

tests/pysyntax/test_struct.py:1

  • This assertion compares struct_a_copy to itself instead of checking all three values. Should be assert struct_a == struct_a_copy == struct_a_equals.
# Copyright 2023-2025, Peter Birch, mailto:[email protected]

tests/pysyntax/test_union.py:1

  • This assertion compares union_a_copy to itself instead of checking all three values. Should be assert union_a == union_a_copy == union_a_equals.
# Copyright 2023-2025, Peter Birch, mailto:[email protected]

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@OisinRobinson OisinRobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good to me.

@Intuity Intuity merged commit 7afa5b5 into main Nov 13, 2025
5 checks passed
@Intuity Intuity deleted the intuity/pt-updates branch November 13, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants