Skip to content

Commit

Permalink
use ... for undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea committed Jul 14, 2022
1 parent 9077af6 commit 5174ec4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
6 changes: 5 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import functools
import os
import re
import sys
from pathlib import Path
from typing import Any, Callable, TypeVar

Expand Down Expand Up @@ -160,7 +161,10 @@ def test_python(session: Session) -> None:
"""Run all Python checks"""
session.notify("test_python_suite", posargs=session.posargs)
session.notify("test_python_types")
session.notify("test_python_style")
if sys.version_info >= (3, 10):
session.notify("test_python_style")
else:
session.log("Skipping type checking - Python<3.10")
session.notify("test_python_build")


Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ ensure_newline_before_comments = "True"
include_trailing_comma = "True"
line_length = 88
lines_after_imports = 2

[tool.mypy]
ignore_missing_imports = "True"
warn_unused_configs = "True"
warn_redundant_casts = "True"
warn_unused_ignores = "True"
6 changes: 0 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
[bdist_wheel]
universal=1

[mypy]
ignore_missing_imports = True
warn_unused_configs = True
warn_redundant_casts = True
warn_unused_ignores = True

[flake8]
ignore = E203, E266, E501, W503, F811, N802, N806
per-file-ignores =
Expand Down
6 changes: 6 additions & 0 deletions src/idom/_py_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__all__ = ["EllipsisType"]

try:
from types import EllipsisType
except ImportError:
EllipsisType = type(Ellipsis) # pragma: no cover
2 changes: 1 addition & 1 deletion src/idom/backend/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def run_server() -> None:
if started:
loop.call_soon_threadsafe(started.set)
try:
server.current.serve_forever() # type: ignore
server.current.serve_forever()
finally:
loop.call_soon_threadsafe(stopped.set)

Expand Down
9 changes: 6 additions & 3 deletions src/idom/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from __future__ import annotations

from html.parser import HTMLParser as _HTMLParser
from typing import Any, Callable, Dict, Generic, List, Optional, Tuple, TypeVar

from ._py_compat import EllipsisType


_RefValue = TypeVar("_RefValue")
_UNDEFINED: Any = object()


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

__slots__ = "current"

def __init__(self, initial_value: _RefValue = _UNDEFINED) -> None:
if initial_value is not _UNDEFINED:
def __init__(self, initial_value: _RefValue | EllipsisType = ...) -> None:
if initial_value is not ...:
self.current = initial_value
"""The present value"""

Expand Down

0 comments on commit 5174ec4

Please sign in to comment.