Skip to content

Regression in mypy 0.930: Cannot override writable attribute "__module__" with a final one #11820

Description

@dvarrazzo

Bug Report

The following code is reported as error by mypy 0.930 (Python 3.8). It seems correct, and was considered correct so far:

from enum import Enum

class PyFormat(str, Enum):
    __module__ = "psycopg.adapt"
    AUTO = "s"
    TEXT = "t"
    BINARY = "b"

The error reported is:

$ mypy test_mypy.py 
test_mypy.py:4: error: Cannot override writable attribute "__module__" with a final one  [misc]

which I don't even know what means...

Activity

  1. sobolevn commented on Dec 22, 2021

    @sobolevn
    Member

    Thanks! Fix is on its way. You can add # type: ignore for now.

  2. dvarrazzo commented on Dec 22, 2021

    @dvarrazzo
    Author

    I'm afraid it will have to be "mypy != 0.930" because there are too many of them and because psycopg is also affected by python/typeshed#6661 😄

    https://github.com/psycopg/psycopg/runs/4610348714?check_suite_focus=true

  3. hauntsaninja commented on Dec 22, 2021

    @hauntsaninja
    Collaborator

    I'll add pyscopg to mypy_primer, so hopefully you'll have fewer regressions in the future :-)

  4. added a commit that references this issue on Dec 22, 2021
  5. dvarrazzo commented on Dec 22, 2021

    @dvarrazzo
    Author

    @hauntsaninja amazing, thank you! And thank you all for the quick turnaround!

  6. added a commit that references this issue on Dec 23, 2021
  7. dvarrazzo commented on Jan 7, 2022

    @dvarrazzo
    Author

    This seems still open in mypy 0.931. In which release is the fix due?

    https://github.com/psycopg/psycopg/runs/4741795872?check_suite_focus=true

  8. hauntsaninja commented on Jan 7, 2022

    @hauntsaninja
    Collaborator

    The commit made it in, but I don't think it actually fixed the issue (as also evidenced by the lack of a primer diff on that PR). I can still repro on both master and 0.931, cc @sobolevn

  9. sobolevn commented on Jan 9, 2022

    @sobolevn
    Member

    I am so sorry 🤦
    I've literally confused and and or operations.

    Tests didn't catch this, because in tests __module__ is not defined on object.
    Now it should be fine! I've double checked it locally.

    Снимок экрана 2022-01-09 в 16 01 55

  10. dvarrazzo commented on Jan 9, 2022

    @dvarrazzo
    Author

    No worries, @sobolevn: your work is very appreciated 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions