Skip to content

auto_detect in mypy #793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hynek opened this issue Apr 15, 2021 · 1 comment
Closed

auto_detect in mypy #793

hynek opened this issue Apr 15, 2021 · 1 comment
Labels
Typing Typing/stub/Mypy/PyRight related bugs.

Comments

@hynek
Copy link
Member

hynek commented Apr 15, 2021

Opening here for discussion, before moving into mypy's bug tracker.

It just painfully occurred to me that mypy doesn't support auto_detect=True which is True by default in NG.

E.g. in

@attr.define
class SortableTableHeaders:
    headers: dict[str, str]
    default: str

    def __init__(self, names: tuple[str, ...]) -> None:
        def normalize(s: str) -> str:
            return s.replace(" ", "-").lower()

        self.default = normalize(names[0])
        self.headers = {normalize(n): n for n in names}

it forces you to pass init=False to define. Has that been raise to mypy? Would it be hard to implement? I think that's a really nice feature and am surprised myself, I didn't notice it before. @euresti any ideas?

@euresti
Copy link
Contributor

euresti commented Apr 15, 2021

I implemented the auto_detecting of attribs. But nothing else. You can file it there, but they'll probably just ping me about fixing it. Unless someone else is excited about learning the mypy plugin code. :)

@wsanchez wsanchez added the Typing Typing/stub/Mypy/PyRight related bugs. label Aug 23, 2021
@hynek hynek closed this as completed Apr 5, 2022
meshy added a commit to meshy/mypy that referenced this issue Dec 23, 2023
This test demonstrates that addition of dunder methods in attrs classes
isn't quite complete.

While the existing test demonstrates that it was working for classes
defined with `init=False`, the `__attrs_init__` method wasn't generated
in the same way when `__init__` was defined with `auto_detect=True`
enabled (either explicitly, or by default).

This auto-generated `__attrs_init__` has been enabled in Attrs as of
version 21.1.0.

Related to: python#10328
Ref: python-attrs/attrs#793
Ref: https://www.attrs.org/en/stable/changelog.html
meshy added a commit to meshy/mypy that referenced this issue Dec 23, 2023
This test demonstrates that addition of dunder methods in attrs classes
isn't quite complete.

While the existing test demonstrates that it was working for classes
defined with `init=False`, the `__attrs_init__` method wasn't generated
in the same way when `__init__` was defined with `auto_detect=True`
enabled (either explicitly, or by default).

This auto-generated `__attrs_init__` has been enabled in Attrs as of
version 21.1.0.

Related to: python#10328
Ref: python-attrs/attrs#793
Ref: https://www.attrs.org/en/stable/changelog.html
meshy added a commit to meshy/mypy that referenced this issue Dec 23, 2023
This test demonstrates that addition of dunder methods in attrs classes
isn't quite complete.

While the existing test demonstrates that it was working for classes
defined with `init=False`, the `__attrs_init__` method wasn't generated
in the same way when `__init__` was defined with `auto_detect=True`
enabled (either explicitly, or by default).

This auto-generated `__attrs_init__` has been enabled in Attrs as of
version 21.1.0.

Related to: python#10328
Ref: python-attrs/attrs#793
Ref: https://www.attrs.org/en/stable/changelog.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing Typing/stub/Mypy/PyRight related bugs.
Projects
None yet
Development

No branches or pull requests

3 participants