Skip to content

Commit e4d3b27

Browse files
committed
Check for implicit reexports with mypy
An implicit reexport happens, when a module imports something using the `from ... import ...` pattern, as the imported symbol is visible to the outside world. This check only allows importing from these modules if the symbol is put in `__all__` or renamed to itself using `from A import B as B` This check revealed several fishy imports. See https://mypy.readthedocs.io/en/latest/config_file.html#confval-implicit_reexport
1 parent bc88fea commit e4d3b27

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,6 @@ addopts = "--strict-markers"
5959
markers = [
6060
"integration_test: marks tests as slow integration tests (deselect with '-m \"not integration_test\"')",
6161
]
62+
63+
[tool.mypy]
64+
implicit_reexport = false

src/textual_dev/previews/colors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from textual._color_constants import COLOR_NAME_TO_RGB
12
from textual.app import App, ComposeResult
2-
from textual.color import COLOR_NAME_TO_RGB, Color
3+
from textual.color import Color
34
from textual.containers import Horizontal, Vertical, VerticalScroll
45
from textual.design import ColorSystem
56
from textual.widgets import Button, Footer, Label, Static, TabbedContent

src/textual_dev/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import msgpack
1111
from aiohttp import WSMsgType
12-
from aiohttp.abc import Request
12+
from aiohttp.web_request import Request
1313
from aiohttp.web_ws import WebSocketResponse
1414
from rich.console import Console
1515
from rich.markup import escape

tests/devtools/test_devtools_client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
from aiohttp.web_ws import WebSocketResponse
99
from rich.console import ConsoleDimensions
1010
from rich.panel import Panel
11-
1211
from textual.constants import DEVTOOLS_PORT
13-
from textual_dev.client import DevtoolsClient
14-
from textual_dev.redirect_output import DevtoolsLog
15-
12+
from textual_dev.client import DevtoolsClient, DevtoolsLog
1613
from utilities.wait_for_predicate import wait_for_predicate
1714

1815
CALLER_LINENO = 123

0 commit comments

Comments
 (0)