Skip to content

Commit e67fedf

Browse files
authored
Remove python2 logic from plugins/attrs.py (#13268)
1 parent 6180a26 commit e67fedf

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

mypy/plugins/attrs.py

-21
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
from mypy.typevars import fill_typevars
6666
from mypy.util import unmangle
6767

68-
KW_ONLY_PYTHON_2_UNSUPPORTED: Final = "kw_only is not supported in Python 2"
69-
7068
# The names of the different functions that create classes or arguments.
7169
attr_class_makers: Final = {"attr.s", "attr.attrs", "attr.attributes"}
7270
attr_dataclass_makers: Final = {"attr.dataclass"}
@@ -295,22 +293,6 @@ def attr_class_maker_callback(
295293
kw_only = _get_decorator_bool_argument(ctx, "kw_only", False)
296294
match_args = _get_decorator_bool_argument(ctx, "match_args", True)
297295

298-
early_fail = False
299-
if ctx.api.options.python_version[0] < 3:
300-
if auto_attribs:
301-
ctx.api.fail("auto_attribs is not supported in Python 2", ctx.reason)
302-
early_fail = True
303-
if not info.defn.base_type_exprs:
304-
# Note: This will not catch subclassing old-style classes.
305-
ctx.api.fail("attrs only works with new-style classes", info.defn)
306-
early_fail = True
307-
if kw_only:
308-
ctx.api.fail(KW_ONLY_PYTHON_2_UNSUPPORTED, ctx.reason)
309-
early_fail = True
310-
if early_fail:
311-
_add_empty_metadata(info)
312-
return True
313-
314296
for super_info in ctx.cls.info.mro[1:-1]:
315297
if "attrs_tag" in super_info.metadata and "attrs" not in super_info.metadata:
316298
# Super class is not ready yet. Request another pass.
@@ -585,9 +567,6 @@ def _attribute_from_attrib_maker(
585567
# Note: If the class decorator says kw_only=True the attribute is ignored.
586568
# See https://github.com/python-attrs/attrs/issues/481 for explanation.
587569
kw_only |= _get_bool_argument(ctx, rvalue, "kw_only", False)
588-
if kw_only and ctx.api.options.python_version[0] < 3:
589-
ctx.api.fail(KW_ONLY_PYTHON_2_UNSUPPORTED, stmt)
590-
return None
591570

592571
# TODO: Check for attr.NOTHING
593572
attr_has_default = bool(_get_argument(rvalue, "default"))

0 commit comments

Comments
 (0)