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

[engine] Fix some type hints when request is passed #9077

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

Marishka17
Copy link
Contributor

@Marishka17 Marishka17 commented Feb 7, 2025

Motivation and context

Since we are adding custom attributes to the request object (such as uuid or iam_context), using the Request type is no longer appropriate.
Based on #9075

How has this been tested?

Checklist

  • I submit my changes into the develop branch
    - [ ] I have created a changelog fragment
    - [ ] I have updated the documentation accordingly
    - [ ] I have added tests to cover my changes
    - [ ] I have linked related issues (see GitHub docs)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2025

Codecov Report

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

Project coverage is 73.92%. Comparing base (fec040d) to head (51a1554).
Report is 7 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9077      +/-   ##
===========================================
+ Coverage    73.75%   73.92%   +0.17%     
===========================================
  Files          428      429       +1     
  Lines        44514    44546      +32     
  Branches      3881     3881              
===========================================
+ Hits         32830    32932     +102     
+ Misses       11684    11614      -70     
Components Coverage Δ
cvat-ui 77.44% <ø> (-0.03%) ⬇️
cvat-server 71.02% <99.17%> (+0.34%) ⬆️

cvat/apps/engine/backup.py Outdated Show resolved Hide resolved
cvat/apps/engine/backup.py Outdated Show resolved Hide resolved
cvat/apps/engine/mixins.py Outdated Show resolved Hide resolved
cvat/apps/engine/types.py Show resolved Hide resolved
from cvat.apps.iam.middleware import WithIAMContext


class PatchedRequest(HttpRequest, Request, WithUUID, WithIAMContext):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think PatchedRequest gives off the wrong idea. "Patched" implies some sort of change, but we only add new attributes. How about something like ExtendedRequest or AugmentedRequest?

Copy link
Contributor

Choose a reason for hiding this comment

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

How about just engine.types.Request?

Copy link
Contributor

Choose a reason for hiding this comment

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

How about just engine.types.Request?

IMO, it's too ambiguous. But if both you and @Marishka17 prefer it, I'm not going to object.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, it should be something like HttpRequest or ApiRequest, but we need to avoid confusion with other requests we already have, such as function requests or async operation requests. I'm not sure this module (called types) is a good place for such an abstraction, maybe it should be something server API or http related (e.g. we already have view_uitls).

Copy link
Contributor

Choose a reason for hiding this comment

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

HttpRequest would be ambiguous too (since it's the name of the base Django type).

if request.method == 'OPTIONS':
return self._tus_response(status=status.HTTP_204)
return self._tus_response(status=status.HTTP_204_NO_CONTENT)
Copy link
Contributor

@SpecLad SpecLad Feb 10, 2025

Choose a reason for hiding this comment

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

That's interesting... was this broken before? If so, you should probably add a changelog entry, as this is a user-visible change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it was
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Mind adding the changelog entry, then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants