Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
jokasimr committed Apr 15, 2024
1 parent a35f291 commit 6f5f4da
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/sciline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def _get_provider(

if provider := self._providers.get(tp):
# Optimization to quickly find non-generic providers
matches = [(provider, {})]
matches: List[Tuple[Provider, Dict[TypeVar, Key]]] = [(provider, {})]
else:
matches = [
(provider, bound)
Expand All @@ -568,28 +568,30 @@ def _get_provider(
)
else:
origin = get_origin(tp)
typevars_of_generic = _extract_typevars_from_generic_type(origin)
if typevars_of_generic:
explanation = [
''.join(
map(
str,
(
'Note that ',
key_name(origin[typevars_of_generic]),
' has constraints ',
# Not sure this is necessary, but mypy complains
if isinstance(origin, type) and hasattr(origin, '__getitem__'):
typevars_of_generic = _extract_typevars_from_generic_type(origin)
if typevars_of_generic:
explanation = [
''.join(
map(
str,
(
{
key_name(tv): tuple(
map(key_name, tv.__constraints__)
)
for tv in typevars_of_generic
}
'Note that ',
key_name(origin[typevars_of_generic]),
' has constraints ',
(
{
key_name(tv): tuple(
map(key_name, tv.__constraints__)
)
for tv in typevars_of_generic
}
),
),
),
)
)
)
]
]
return handler.handle_unsatisfied_requirement(tp, *explanation), {}

def _get_unique_provider(
Expand Down

0 comments on commit 6f5f4da

Please sign in to comment.