Skip to content

mypy strict mode doesn't play well with less-specific slack_sdk.model imports  #1209

@kezabelle

Description

@kezabelle

Kinda terrible title, dunno how to be super succinct with it. Apologies.

In PyCharm, given the file:

class MyBlock(InputBlock):
    pass

Letting it auto-generate the import (OSX keyboard combo Option + Enter when over the invalid token InputBlock) will turn the file into:

from slack_sdk.models.blocks import InputBlock


class MyBlock(InputBlock):
    pass

If I then save that file as testing.py and run mypy --strict --show-error-codes testing.py I'll get:

testing.py:1: error: Module "slack_sdk.models.blocks" does not explicitly export attribute "InputBlock"; implicit reexport disabled  [attr-defined]

because the __init__ for the blocks module doesn't include an __all__ entry to re-export them as actually ostensibly public.

Ideally, the solution is to provide an __all__ here, so that anyone using mypy in strict mode doesn't have to "work around" the level of strictness for their project by doing something like the following in their mypy.ini (though naturally that solution does exist):

[mypy-slack_sdk.models.blocks]
implicit_reexport = True

Category

  • slack_sdk.models (UI component builders)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions