Skip to content

Commit 5174ec4

Browse files
committed
use ... for undefined
1 parent 9077af6 commit 5174ec4

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import functools
44
import os
55
import re
6+
import sys
67
from pathlib import Path
78
from typing import Any, Callable, TypeVar
89

@@ -160,7 +161,10 @@ def test_python(session: Session) -> None:
160161
"""Run all Python checks"""
161162
session.notify("test_python_suite", posargs=session.posargs)
162163
session.notify("test_python_types")
163-
session.notify("test_python_style")
164+
if sys.version_info >= (3, 10):
165+
session.notify("test_python_style")
166+
else:
167+
session.log("Skipping type checking - Python<3.10")
164168
session.notify("test_python_build")
165169

166170

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ ensure_newline_before_comments = "True"
1010
include_trailing_comma = "True"
1111
line_length = 88
1212
lines_after_imports = 2
13+
14+
[tool.mypy]
15+
ignore_missing_imports = "True"
16+
warn_unused_configs = "True"
17+
warn_redundant_casts = "True"
18+
warn_unused_ignores = "True"

setup.cfg

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
[bdist_wheel]
22
universal=1
33

4-
[mypy]
5-
ignore_missing_imports = True
6-
warn_unused_configs = True
7-
warn_redundant_casts = True
8-
warn_unused_ignores = True
9-
104
[flake8]
115
ignore = E203, E266, E501, W503, F811, N802, N806
126
per-file-ignores =

src/idom/_py_compat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__all__ = ["EllipsisType"]
2+
3+
try:
4+
from types import EllipsisType
5+
except ImportError:
6+
EllipsisType = type(Ellipsis) # pragma: no cover

src/idom/backend/flask.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def run_server() -> None:
8585
if started:
8686
loop.call_soon_threadsafe(started.set)
8787
try:
88-
server.current.serve_forever() # type: ignore
88+
server.current.serve_forever()
8989
finally:
9090
loop.call_soon_threadsafe(stopped.set)
9191

src/idom/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from __future__ import annotations
2+
13
from html.parser import HTMLParser as _HTMLParser
24
from typing import Any, Callable, Dict, Generic, List, Optional, Tuple, TypeVar
35

6+
from ._py_compat import EllipsisType
7+
48

59
_RefValue = TypeVar("_RefValue")
6-
_UNDEFINED: Any = object()
710

811

912
class Ref(Generic[_RefValue]):
@@ -19,8 +22,8 @@ class Ref(Generic[_RefValue]):
1922

2023
__slots__ = "current"
2124

22-
def __init__(self, initial_value: _RefValue = _UNDEFINED) -> None:
23-
if initial_value is not _UNDEFINED:
25+
def __init__(self, initial_value: _RefValue | EllipsisType = ...) -> None:
26+
if initial_value is not ...:
2427
self.current = initial_value
2528
"""The present value"""
2629

0 commit comments

Comments
 (0)