Skip to content

Commit e9ac543

Browse files
fredriktc00kiemon5ter
authored andcommitted
Fix initial issues reported by mypy.
1 parent 4d77c55 commit e9ac543

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

src/saml2/__init__.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"""
1818

1919
import logging
20+
from typing import Any
21+
from typing import Optional
22+
from typing import Union
2023
from xml.etree import ElementTree
2124

2225
import defusedxml.ElementTree
@@ -433,14 +436,14 @@ class SamlBase(ExtensionContainer):
433436
nodes into ExtensionElements.
434437
"""
435438

436-
c_children = {}
437-
c_attributes = {}
438-
c_attribute_type = {}
439-
c_child_order = []
440-
c_cardinality = {}
441-
c_any = None
442-
c_any_attribute = None
443-
c_value_type = None
439+
c_children: Any = {}
440+
c_attributes: Any = {}
441+
c_attribute_type: Any = {}
442+
c_child_order: list[str] = []
443+
c_cardinality: dict[str, dict[str, int]] = {}
444+
c_any: Optional[dict[str, str]] = None
445+
c_any_attribute: Optional[dict[str, str]] = None
446+
c_value_type: Any = None
444447
c_ns_prefix = None
445448

446449
def _get_all_c_children_with_order(self):

src/saml2/authn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,5 @@ def _verify(self, pwd, user):
269269

270270
except ImportError:
271271

272-
class LDAPAuthn(UserAuthnMethod):
272+
class LDAPAuthn(UserAuthnMethod): # type: ignore[no-redef]
273273
pass

src/saml2/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ def artifact2destination(self, artifact, descriptor):
15831583

15841584
typecode = _art[:2]
15851585
if typecode != ARTIFACT_TYPECODE:
1586-
raise ValueError(f"Invalid artifact typecode '{typecode}' should be {ARTIFACT_TYPECODE}")
1586+
raise ValueError(f"Invalid artifact typecode {repr(typecode)} should be {repr(ARTIFACT_TYPECODE)}")
15871587

15881588
try:
15891589
endpoint_index = str(int(_art[2:4]))

src/saml2/httputil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from http.cookies import SimpleCookie
55
import logging
66
import time
7+
from typing import Optional
78
from urllib.parse import parse_qs
89
from urllib.parse import quote
910

@@ -22,7 +23,7 @@
2223

2324

2425
class Response:
25-
_template = None
26+
_template: Optional[str] = None
2627
_status = "200 OK"
2728
_content_type = "text/html"
2829
_mako_template = None

src/saml2/pack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
try:
1414
import html
1515
except Exception:
16-
import cgi as html
16+
import cgi as html # type: ignore[no-redef]
1717

1818
import logging
1919
from urllib.parse import urlencode

src/saml2/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
try:
22
from importlib.metadata import version as _resolve_package_version
33
except ImportError:
4-
from importlib_metadata import version as _resolve_package_version
4+
from importlib_metadata import version as _resolve_package_version # type: ignore[no-redef]
55

66

77
def _parse_version():

0 commit comments

Comments
 (0)