The methods in the BasePermission class have incorrect return type inference #9955
Unanswered
hussein-m-kandil
asked this question in
Potential Issue
Replies: 1 comment 1 reply
|
Although it may seem like a valid reason, but writing there is a much simpler solution; class BasePermission(metaclass=BasePermissionMetaclass):
def has_permission(self, request, view) -> bool: # just adding type hint
return TrueAlthough it may seem like an insignificant extra step, the “bool(True)” operation in your solution involves a conversion. Specifically, it involves transitioning from a “pure” conversion to a constructor call. If you create a pull request on this issue and proceed with the solution I suggested—in my opinion—you’ll be making a much more acceptable PR. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The
has_permissionandhas_object_permissionmethods in theBasePermissionclass currently returnTrue, which leads their return type to be inferred asLiteral[True].I suggest returning
bool(True)from the methods so their return type is inferred asbool.All reactions