Skip to content

feat: expand target-version support #90

Closed
b-long wants to merge 13 commits intodevelopfrom
feat/expand-target-mode
Closed

feat: expand target-version support #90
b-long wants to merge 13 commits intodevelopfrom
feat/expand-target-mode

Conversation

@b-long
Copy link
Owner

@b-long b-long commented Sep 10, 2025

No description provided.

* chore: update pre-commit

* fix: type annotations in tdf.py

* chore: expand inspect tests

* chore: cleanup tests

* chore: organize imports

* chore: require sorted imports

* chore: add test_cli_decrypt.py

* chore: organize integration tests

* chore: organize integration tests

* Tweak attributes

* chore: cleanup tests

* chore: cleanup tests
* chore: dry tests

* chore: relocate run_cli_inspect

* chore: fix type annotation

* chore: note token isn't important

* chore: cleanup args & typing

* chore: extract 'get_platform_url' function

* chore: extract 'support_otdfctl_args' module

* chore: use '*get_cli_flags()' pattern

* chore: DRY code

* chore: DRY code

* chore: extract 'get_testing_environ' function

* chore: DRY code

* chore: DRY code

* chore: DRY code
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @b-long, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's ability to work with and validate Trusted Data Format (TDF) files across different specification versions. It introduces a robust framework for generating and testing TDFs from various sources, ensuring compatibility and correctness. Beyond expanding TDF version support, the changes also refine the command-line interface and improve overall code quality.

Highlights

  • Expanded Target Version Support: Introduced comprehensive testing infrastructure to support and validate TDF files generated for different target specification versions (e.g., v4.2.2, v4.3.1). This includes new pytest fixtures and helper functions to generate and manage TDF files using otdfctl for various target modes.
  • Refactored Integration Tests: The integration test suite has been significantly reorganized into dedicated directories (otdfctl_only, otdfctl_to_python, python_only) to clearly separate tests based on the tools involved. New test files specifically validate CLI decryption and inspection capabilities against TDFs created with different target versions.
  • CLI Enhancements and Robustness: The inspect command in the Python CLI now gracefully handles authentication failures by attempting to proceed with a minimal SDK for basic metadata inspection. Command-line argument parsing and execution for both encryption and decryption have been standardized using new helper functions for improved consistency and maintainability.
  • Code Quality and Formatting Improvements: Applied extensive code formatting and linting across the codebase, primarily reordering imports using isort rules and updating ruff configurations. This enhances code readability and adheres to established Python style guidelines.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a significant improvement, successfully expanding support for different target versions of the TDF specification. The introduction of new integration tests for versions v4.2.2 and v4.3.1 is a major highlight, ensuring backward compatibility and future-proofing the SDK. The extensive refactoring of the test suite is particularly commendable. By creating dedicated helper modules (support_cli_args.py, support_common.py, support_otdfctl_args.py), the tests have become much more readable, maintainable, and robust. Furthermore, the codebase has been cleaned up by enabling and applying isort rules via ruff, leading to consistent import ordering across all Python files. I have one minor suggestion regarding a type hint that could be made more flexible. Overall, this is a high-quality contribution.

Comment on lines 279 to 284
self,
payload: bytes | BinaryIO,
config: TDFConfig,
output_stream: BinaryIO | None = None,
output_stream: io.BytesIO | None = None,
):
if output_stream is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The type hint for output_stream was changed to io.BytesIO | None, which is more restrictive than the previous BinaryIO | None. The implementation can handle any file-like object that supports binary writing (like a file opened on disk with open('file.tdf', 'wb')), which is what the typing.BinaryIO protocol represents. Reverting to BinaryIO would make the type hint more accurate and flexible for consumers of this method.

    def create_tdf(
        self,
        payload: bytes | BinaryIO,
        config: TDFConfig,
        output_stream: BinaryIO | None = None,
    ):

@b-long b-long closed this Sep 10, 2025
@b-long b-long deleted the feat/expand-target-mode branch September 10, 2025 14:04
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.

1 participant