Skip to content

Hybrid behavior doesn't work when maybe_cls=None and no annotations #673

@euresti

Description

@euresti

The doc says:

    :param Optional[bool] auto_attribs: If set to `True` or `False`, it behaves
       exactly like `attr.s`. If left `None`, `attr.s` will try to guess:

       1. If all attributes are annotated and no `attr.ib` is found, it assumes
          *auto_attribs=True*.
       2. Otherwise it assumes *auto_attribs=False* and tries to collect
          `attr.ib`\ s.

Sadly it doesn't exactly work.

import attr

@attr.define()
class Trigger:
    a = attr.field()

The code does this:

    try:
        return do_it(True)
    except UnannotatedAttributeError:
        return do_it(False)

But do_it itself won't raise UnannotatedAttributeError until the decorator is applied to the class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions