Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Lib/ldap/cidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@
TypeVar,
)

T = TypeVar('T', bound=Any)
_T = TypeVar('_T', bound=Any)

if TYPE_CHECKING:
from typing_extensions import Self


class cidict(MutableMappingType[str, T]):
class cidict(MutableMappingType[str, _T]):
"""
Case-insensitive but case-respecting dictionary.
"""
__slots__ = ('_keys', '_data')

def __init__(self, default: Mapping[str, T] | None = None) -> None:
def __init__(self, default: Mapping[str, _T] | None = None) -> None:
self._keys: dict[str, str] = {}
self._data: dict[str, T] = {}
self._data: dict[str, _T] = {}
if default:
self.update(default)

# MutableMapping abstract methods

def __getitem__(self, key: str) -> T:
def __getitem__(self, key: str) -> _T:
return self._data[key.lower()]

def __setitem__(self, key: str, value: T) -> None:
def __setitem__(self, key: str, value: _T) -> None:
lower_key = key.lower()
self._keys[lower_key] = key
self._data[lower_key] = value
Expand Down Expand Up @@ -85,7 +85,7 @@ def has_key(self, key: str) -> bool:
return key in self

@property
def data(self) -> dict[str, T]:
def data(self) -> dict[str, _T]:
"""Compatibility with older IterableUserDict-based implementation"""
warnings.warn(
'ldap.cidict.cidict.data is an internal attribute; it may be ' +
Expand Down
16 changes: 8 additions & 8 deletions Lib/ldap/schema/subentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
DITContentRule,
)

SchemaElementSubclass = TypeVar('SchemaElementSubclass', bound=SchemaElement)
_SchemaElementSubclass = TypeVar('_SchemaElementSubclass', bound=SchemaElement)

SCHEMA_ATTRS = list(SCHEMA_CLASS_MAPPING)

Expand Down Expand Up @@ -273,7 +273,7 @@ def tree(

def getoid(
self,
se_class: type[SchemaElementSubclass],
se_class: type[_SchemaElementSubclass],
nameoroid: str,
raise_keyerror: int = 0,
) -> str:
Expand All @@ -297,7 +297,7 @@ def getoid(

def get_inheritedattr(
self,
se_class: type[SchemaElementSubclass],
se_class: type[_SchemaElementSubclass],
nameoroid: str,
name: str,
) -> Any:
Expand Down Expand Up @@ -326,11 +326,11 @@ def get_inheritedattr(

def get_obj(
self,
se_class: type[SchemaElementSubclass],
se_class: type[_SchemaElementSubclass],
nameoroid: str,
default: SchemaElementSubclass | None = None,
default: _SchemaElementSubclass | None = None,
raise_keyerror: int = 0,
) -> SchemaElementSubclass | None:
) -> _SchemaElementSubclass | None:
"""
Get a schema element by name or OID
"""
Expand All @@ -353,10 +353,10 @@ def get_obj(

def get_inheritedobj(
self,
se_class: type[SchemaElementSubclass],
se_class: type[_SchemaElementSubclass],
nameoroid: str,
inherited: list[str] | None = None,
) -> SchemaElementSubclass | None:
) -> _SchemaElementSubclass | None:
"""
Get a schema element by name or OID with all class attributes
set including inherited class attributes
Expand Down
4 changes: 2 additions & 2 deletions Lib/slapdtest/_slapdtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
HAVE_LDAPI = hasattr(socket, 'AF_UNIX')


T = TypeVar('T', bound=Any)
_T = TypeVar('_T', bound=Any)

def identity(test_item: T) -> T:
def identity(test_item: _T) -> _T:
"""Identity decorator

"""
Expand Down