Skip to content

Comments

make parse_c module isolate#764

Merged
lucemia merged 2 commits intomainfrom
migrate-parse-c-schema-back
Jul 9, 2025
Merged

make parse_c module isolate#764
lucemia merged 2 commits intomainfrom
migrate-parse-c-schema-back

Conversation

@lucemia
Copy link
Contributor

@lucemia lucemia commented Jul 9, 2025

This pull request introduces significant changes to improve the handling and representation of FFmpeg command-line options in the codebase. The most important updates include the addition of a new schema module defining FFMpegOption and related enums, refactoring imports to use the new schema, and enhancing the load_options function to utilize the updated FFMpegOption structure.

Schema Enhancements:

  • src/scripts/parse_c/schema.py: Added a new schema module defining FFMpegOption, FFMpegOptionType, and FFMpegOptionFlag. This provides a structured and extensible way to represent FFmpeg options, including properties for input/output/global options and stream specifier support.

Refactoring for Schema Integration:

Functional Improvements:

  • src/scripts/code_gen/cli.py: Enhanced the load_options function to construct FFMpegOption objects using the new FFMpegOptionType enum and other schema properties, providing better type safety and clarity.

Minor Updates:

@lucemia lucemia requested a review from Copilot July 9, 2025 02:06
@lucemia lucemia marked this pull request as ready for review July 9, 2025 02:07
Copy link
Contributor

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 a standalone schema module for FFmpeg options, refactors existing parsing code to use it, and updates code generation to build options via the new schema.

  • Added schema.py defining FFMpegOption, FFMpegOptionType, and FFMpegOptionFlag.
  • Updated imports in parsing utilities to reference the new schema.
  • Enhanced load_options in code generation to construct FFMpegOption objects using the new enums.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/scripts/parse_c/schema.py New schema definitions for FFmpeg options (types, flags, dataclass)
src/scripts/parse_c/parse_ffmpeg_opt_c.py Refactored imports to use .schema for FFMpegOption and flags
src/scripts/parse_c/cli.py Updated import to .schema (unused import may be removable)
src/scripts/code_gen/cli.py Improved load_options to rebuild options with the new schema
Comments suppressed due to low confidence (2)

src/scripts/parse_c/schema.py:185

  • [nitpick] The property name is_support_stream_specifier is a bit awkward; consider renaming it to supports_stream_specifier for clarity and consistency with boolean naming conventions.
    def is_support_stream_specifier(self) -> bool:

src/scripts/parse_c/cli.py:16

  • FFMpegOption is imported but not used in this module; consider removing the unused import to reduce clutter and dependencies.
from .schema import FFMpegOption

options = [
FFMpegOption(
name=i.name,
type=FFMpegOptionType(i.type.value),
Copy link

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

You can directly assign the enum instance (type=i.type) instead of re-wrapping it with FFMpegOptionType(i.type.value), simplifying the code and avoiding redundant conversion.

Suggested change
type=FFMpegOptionType(i.type.value),
type=i.type,

Copilot uses AI. Check for mistakes.

options = parse_c.cli.parse_ffmpeg_options()
options = [
FFMpegOption(
Copy link

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

When recreating FFMpegOption instances, optional fields like argname and canon are omitted; include argname=i.argname and canon=i.canon to preserve these values.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jul 9, 2025

Codecov Report

Attention: Patch coverage is 98.75000% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.98%. Comparing base (2535d30) to head (959a2c7).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/scripts/code_gen/cli.py 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #764      +/-   ##
==========================================
+ Coverage   80.89%   87.98%   +7.09%     
==========================================
  Files          77       27      -50     
  Lines        4469     1215    -3254     
==========================================
- Hits         3615     1069    -2546     
+ Misses        854      146     -708     
Flag Coverage Δ
3.10 ?
3.11 ?
3.12 ?
backend ?
python ?
python-3.10 87.98% <98.75%> (+0.81%) ⬆️
scripts 87.98% <98.75%> (+0.81%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scripts/parse_c/cli.py 81.81% <100.00%> (ø)
src/scripts/parse_c/parse_ffmpeg_opt_c.py 100.00% <100.00%> (ø)
src/scripts/parse_c/schema.py 100.00% <100.00%> (ø)
src/scripts/code_gen/cli.py 41.74% <0.00%> (ø)

... and 51 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lucemia lucemia merged commit a92aaeb into main Jul 9, 2025
10 checks passed
@lucemia lucemia deleted the migrate-parse-c-schema-back branch July 9, 2025 02:18
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