From 47d5a7cdf084f6c25d3afc6cdf494a53bf4db091 Mon Sep 17 00:00:00 2001 From: Cheaterman Date: Mon, 16 Jun 2025 17:51:19 +0200 Subject: [PATCH] Fix role kwarg type in login_required Closes #6 --- flask_httpauth-stubs/__init__.pyi | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/flask_httpauth-stubs/__init__.pyi b/flask_httpauth-stubs/__init__.pyi index bb6cde3..553d3b3 100644 --- a/flask_httpauth-stubs/__init__.pyi +++ b/flask_httpauth-stubs/__init__.pyi @@ -1,11 +1,14 @@ from typing import ( Callable, + List, Optional, - Tuple, Union, ) from werkzeug.datastructures import Authorization +RoleType = Optional[Union[str, List[str], List[List[str]]]] + + class HTTPAuth: def __init__( self, @@ -28,7 +31,7 @@ class HTTPAuth: def authenticate_header(self) -> str: ... def authorize( self, - role: Optional[Union[Tuple[str, str], Tuple[Tuple[str, str]], str]], + role: RoleType, user: Union[str, bool], auth: Optional[Authorization], ) -> Optional[bool]: ... @@ -41,7 +44,7 @@ class HTTPAuth: def login_required( self, f: Optional[Callable] = ..., - role: Optional[Union[Tuple[str, str], Tuple[Tuple[str, str]], str]] = ..., + role: RoleType = ..., optional: Optional[bool] = ..., ) -> Callable: ... def username(self) -> str: ... @@ -131,5 +134,7 @@ class MultiAuth: self.additional_auth = args def current_user(self) -> Optional[str]: ... def login_required( - self, f: Optional[Callable] = ..., role: Optional[str] = ... + self, + f: Optional[Callable] = ..., + role: RoleType = ..., ) -> Callable: ...