Browse Source

flag_value should not be a generic class

Since there is no generic information in `flag_value.__init__()`, 
`flag_value` descriptors get stored as `flag_value[<nothing>]` in mypy
strict mode and then the `__get__` overloads never match. This leads to
errors when using things like `permissions_instance.embed_links` since
`<nothing>` never matches `Permissions`. 

The generic inheritance isn't needed at all since the type information
we care about comes from the call site of `__get__` and not the 
instantiation of the descriptor.
pull/7373/head
Bryan Forbes 4 years ago
committed by GitHub
parent
commit
79bae47992
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      discord/flags.py

2
discord/flags.py

@ -41,7 +41,7 @@ FV = TypeVar('FV', bound='flag_value')
BF = TypeVar('BF', bound='BaseFlags')
class flag_value(Generic[BF]):
class flag_value:
def __init__(self, func: Callable[[Any], int]):
self.flag = func(None)
self.__doc__ = func.__doc__

Loading…
Cancel
Save