Skip to content

Note in our stubs re PyCharm #415

@hynek

Description

@hynek

Our stubs have currently this block:

# NOTE: We had several choices for the annotation to use for type arg:
# 1) Type[_T]
#   - Pros: works in PyCharm without plugin support
#   - Cons: produces less informative error in the case of conflicting TypeVars
#     e.g. `attr.ib(default='bad', type=int)`
# 2) Callable[..., _T]
#   - Pros: more informative errors than #1
#   - Cons: validator tests results in confusing error.
#     e.g. `attr.ib(type=int, validator=validate_str)`
# 3) type (and do all of the work in the mypy plugin)
#   - Pros: in mypy, the behavior of type argument is exactly the same as with
#     annotations.
#   - Cons: completely disables type inspections in PyCharm when using the
#     type arg.
# We chose option #1 until either PyCharm adds support for attrs, or python 2
# reaches EOL.

PyCharm now does support attrs. Should we do something about it before releasing the stubs for the first time or is it fine as it is?

cc @euresti @chadrik (sorry…)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions