|
65 | 65 | from mypy.typevars import fill_typevars |
66 | 66 | from mypy.util import unmangle |
67 | 67 |
|
68 | | -KW_ONLY_PYTHON_2_UNSUPPORTED: Final = "kw_only is not supported in Python 2" |
69 | | - |
70 | 68 | # The names of the different functions that create classes or arguments. |
71 | 69 | attr_class_makers: Final = {"attr.s", "attr.attrs", "attr.attributes"} |
72 | 70 | attr_dataclass_makers: Final = {"attr.dataclass"} |
@@ -295,22 +293,6 @@ def attr_class_maker_callback( |
295 | 293 | kw_only = _get_decorator_bool_argument(ctx, "kw_only", False) |
296 | 294 | match_args = _get_decorator_bool_argument(ctx, "match_args", True) |
297 | 295 |
|
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 | | - |
314 | 296 | for super_info in ctx.cls.info.mro[1:-1]: |
315 | 297 | if "attrs_tag" in super_info.metadata and "attrs" not in super_info.metadata: |
316 | 298 | # Super class is not ready yet. Request another pass. |
@@ -585,9 +567,6 @@ def _attribute_from_attrib_maker( |
585 | 567 | # Note: If the class decorator says kw_only=True the attribute is ignored. |
586 | 568 | # See https://github.com/python-attrs/attrs/issues/481 for explanation. |
587 | 569 | 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 |
591 | 570 |
|
592 | 571 | # TODO: Check for attr.NOTHING |
593 | 572 | attr_has_default = bool(_get_argument(rvalue, "default")) |
|
0 commit comments