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 Nov 24, 2023
1 parent 1b27664 commit 5711b3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions mypy/plugins/attrs.py
Expand Up @@ -318,7 +318,9 @@ def attr_class_maker_callback(
frozen = _get_frozen(ctx, frozen_default)
order = _determine_eq_order(ctx)
slots = _get_decorator_bool_argument(ctx, "slots", slots_default)
hashable = _get_decorator_bool_argument(ctx, "hash", False) or _get_decorator_bool_argument(ctx, "unsafe_hash", False)
hashable = _get_decorator_bool_argument(ctx, "hash", False) or _get_decorator_bool_argument(
ctx, "unsafe_hash", False
)

auto_attribs = _get_decorator_optional_bool_argument(ctx, "auto_attribs", auto_attribs_default)
kw_only = _get_decorator_bool_argument(ctx, "kw_only", False)
Expand Down Expand Up @@ -931,9 +933,13 @@ def _add_match_args(ctx: mypy.plugin.ClassDefContext, attributes: list[Attribute
)
add_attribute_to_class(api=ctx.api, cls=ctx.cls, name="__match_args__", typ=match_args)


def _remove_hashability(ctx: mypy.plugin.ClassDefContext) -> None:
"""Remove hashability from a class."""
add_attribute_to_class(ctx.api, ctx.cls, "__hash__", NoneType(), is_classvar=True, overwrite_existing=True)
add_attribute_to_class(
ctx.api, ctx.cls, "__hash__", NoneType(), is_classvar=True, overwrite_existing=True
)


class MethodAdder:
"""Helper to add methods to a TypeInfo.
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-plugin-attrs.test
Expand Up @@ -2352,4 +2352,4 @@ class A:
a: Hashable = A(1)

[builtins fixtures/plugin_attrs.pyi]
[typing fixtures/typing-full.pyi]
[typing fixtures/typing-full.pyi]

0 comments on commit 5711b3a

Please sign in to comment.