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 Jul 9, 2023
1 parent 02c7e03 commit 00fd471
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions mypy/plugins/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,20 @@ def __init__(
self.is_neither_frozen_nor_nonfrozen = is_neither_frozen_nor_nonfrozen
self._api = api

def to_argument(self, current_info: TypeInfo, *, of: Literal['__init__', 'replace', '__post_init__']) -> Argument:
def to_argument(
self, current_info: TypeInfo, *, of: Literal["__init__", "replace", "__post_init__"]
) -> Argument:
arg_kind = ARG_POS
if of == '__init__':
if of == "__init__":
if self.kw_only and self.has_default:
arg_kind = ARG_NAMED_OPT
elif self.kw_only and not self.has_default:
arg_kind = ARG_NAMED
elif not self.kw_only and self.has_default:
arg_kind = ARG_OPT
elif of == 'replace':
elif of == "replace":
arg_kind = ARG_NAMED if self.is_init_var and not self.has_default else ARG_NAMED_OPT
elif of == '__post_init__':
elif of == "__post_init__":
# We always use `ARG_POS` without a default value, because it is practical.
# Consider this case:
#
Expand Down Expand Up @@ -253,7 +255,7 @@ def transform(self) -> bool:
and attributes
):
args = [
attr.to_argument(info, of='__init__')
attr.to_argument(info, of="__init__")
for attr in attributes
if attr.is_in_init and not self._is_kw_only_type(attr.type)
]
Expand Down Expand Up @@ -1093,7 +1095,7 @@ def check_post_init(api: TypeChecker, defn: FuncItem, info: TypeInfo) -> None:
ideal_sig = ideal_sig_method.type
assert isinstance(ideal_sig, ProperType) # we set it ourselves
assert isinstance(ideal_sig, CallableType)
ideal_sig = ideal_sig.copy_modified(name='__post_init__')
ideal_sig = ideal_sig.copy_modified(name="__post_init__")

api.check_override(
override=defn.type,
Expand Down

0 comments on commit 00fd471

Please sign in to comment.