Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 22, 2024
1 parent aef56bd commit 94fdc4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions astroid/nodes/node_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4719,7 +4719,6 @@ def _infer(


class JoinedStr(NodeNG):

"""Represents a list of string expressions to be joined.
>>> import astroid
Expand Down Expand Up @@ -4787,7 +4786,11 @@ def _infer(
) -> Generator[InferenceResult, None, InferenceErrorInfo | None]:
uninferable_already_generated = False
for inferred in self._infer_from_values(self.values, context):
failed = inferred is util.Uninferable or isinstance(inferred, Const) and MISSING_VALUE in inferred.value
failed = (
inferred is util.Uninferable
or isinstance(inferred, Const)
and MISSING_VALUE in inferred.value
)
if failed and self.FAIL_ON_UNINFERABLE:
if not uninferable_already_generated:
uninferable_already_generated = True
Expand Down Expand Up @@ -4819,7 +4822,9 @@ def _infer_from_values(
yield Const(result)

@classmethod
def _safe_infer_from_node(cls, node: NodeNG, context: InferenceContext | None = None, **kwargs: Any) -> Generator[InferenceResult, None, InferenceErrorInfo | None]:
def _safe_infer_from_node(
cls, node: NodeNG, context: InferenceContext | None = None, **kwargs: Any
) -> Generator[InferenceResult, None, InferenceErrorInfo | None]:
try:
yield from node._infer(context, **kwargs)
except InferenceError:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -7402,13 +7402,13 @@ class Cls:
s1 = f'{c_obj!r}' #@
""",
"<__main__.Cls",
False
False,
),
("s1 = f'{5}' #@", "5", False),
("s1 = f'{missing}'", None, True),
("s1 = f'{missing}'", "{MISSING_VALUE}", False),
("s1 = f'a/{missing}/b'", None, True),
("s1 = f'a/{missing}/b'", "a/{MISSING_VALUE}/b", False)
("s1 = f'a/{missing}/b'", "a/{MISSING_VALUE}/b", False),
],
)
def test_joined_str_returns_string(source, expected, fail) -> None:
Expand Down

0 comments on commit 94fdc4e

Please sign in to comment.