Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type annotations #167

Merged
merged 2 commits into from
May 4, 2024
Merged

Conversation

truongvan
Copy link
Contributor

  • The type annotation container_width: int = None was causing issues with my type checking, so I updated it to container_width: int | None = None.
  • Handle the type of **breakpoints as described in the argument lists section of PEP 484.
  • The variable ratio can be of type str, Fraction, or None. However, using ratio = ratio or (img_width / img_height) assigns a floating-point number, which disrupts type checking.

Replace the floating-point division in the ratio calculation with
Fraction
Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (62988c1) to head (6cc7f32).
Report is 11 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #167      +/-   ##
===========================================
+ Coverage   99.34%   100.00%   +0.65%     
===========================================
  Files          13        13              
  Lines         459       464       +5     
===========================================
+ Hits          456       464       +8     
+ Misses          3         0       -3     
Flag Coverage Δ
celery 83.40% <100.00%> (-0.91%) ⬇️
cleanup 84.05% <100.00%> (-0.92%) ⬇️
dj4.1 84.05% <100.00%> (-0.92%) ⬇️
dj4.2 84.05% <100.00%> (-0.92%) ⬇️
django-rq 83.40% <100.00%> (-0.91%) ⬇️
dramatiq 83.40% <100.00%> (-0.91%) ⬇️
drf 92.88% <100.00%> (+0.07%) ⬆️
macos-latest 84.26% <100.00%> (?)
py3.10 84.05% <100.00%> (-0.92%) ⬇️
py3.12 84.05% <100.00%> (-0.92%) ⬇️
py3.8 84.05% <100.00%> (-0.92%) ⬇️
py3.9 84.05% <100.00%> (-0.92%) ⬇️
ubuntu-latest 84.05% <100.00%> (-0.92%) ⬇️
windows-latest 75.80% <100.00%> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@codingjoe codingjoe left a comment

Choose a reason for hiding this comment

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

Thanks, @truongvan, I appreciate the help!

@codingjoe codingjoe changed the title Add optional annotations for arguments that have a default value of None, and correct the types for keyword arguments. Improve type annotations May 4, 2024
@codingjoe codingjoe merged commit a7585cb into codingjoe:main May 4, 2024
24 checks passed
codingjoe pushed a commit that referenced this pull request May 5, 2024
* Change ratio calculation to use Fraction

Replace the floating-point division in the ratio calculation with
Fraction

* Refine type annotations
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.

None yet

2 participants