Skip to content

Conversation

@semohr
Copy link
Contributor

@semohr semohr commented Dec 7, 2025

This PR adds more comprehensive typing to the mediafile/fields.py module using generics. Fields are now typed as MediaField[T] where T corresponds to the out_type of the field. This allows type checkers and IDEs to more accurately infer field types.

Example:

mf = MediaFile(...)
mf.disc  # type: MediaField[int]

Most fields are still MediaField[unknown], but this PR is a partial step toward fully typed fields. Additional PRs will follow to further improve typing across mediafile.

Now might be a good time to have a look at this to not increase the review burden too much.

@github-actions
Copy link

github-actions bot commented Dec 7, 2025

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2025

Codecov Report

❌ Patch coverage is 96.87500% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.34%. Comparing base (a602f02) to head (5315cb5).

Files with missing lines Patch % Lines
mediafile/utils/type_conversion.py 90.00% 1 Missing and 1 partial ⚠️
mediafile/fields.py 98.92% 0 Missing and 1 partial ⚠️
mediafile/utils/image.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #97      +/-   ##
==========================================
+ Coverage   93.26%   93.34%   +0.08%     
==========================================
  Files          16       17       +1     
  Lines         817      842      +25     
  Branches      118      115       -3     
==========================================
+ Hits          762      786      +24     
+ Misses         35       34       -1     
- Partials       20       22       +2     
Files with missing lines Coverage Δ
mediafile/_types.py 100.00% <100.00%> (ø)
mediafile/constants.py 100.00% <100.00%> (ø)
mediafile/fields.py 94.61% <98.92%> (+1.44%) ⬆️
mediafile/utils/image.py 88.88% <87.50%> (-1.74%) ⬇️
mediafile/utils/type_conversion.py 88.88% <90.00%> (-3.01%) ⬇️

@semohr semohr marked this pull request as ready for review December 7, 2025 14:27
@github-actions
Copy link

github-actions bot commented Dec 7, 2025

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

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