Skip to content

Commit

Permalink
Update type imports for generics
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 16, 2024
1 parent 52bef7c commit b865a10
Show file tree
Hide file tree
Showing 70 changed files with 145 additions and 144 deletions.
3 changes: 2 additions & 1 deletion panel/chat/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import asyncio
import traceback

from collections.abc import Callable
from enum import Enum
from inspect import (
getfullargspec, isasyncgen, isasyncgenfunction, isawaitable,
iscoroutinefunction, isgenerator, isgeneratorfunction, ismethod,
)
from io import BytesIO
from typing import (
TYPE_CHECKING, Any, Callable, ClassVar, Literal,
TYPE_CHECKING, Any, ClassVar, Literal,
)

import param
Expand Down
5 changes: 2 additions & 3 deletions panel/chat/input.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

from typing import (
TYPE_CHECKING, Any, ClassVar, Mapping,
)
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, ClassVar

import param

Expand Down
3 changes: 2 additions & 1 deletion panel/chat/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

from __future__ import annotations

from collections.abc import Callable
from dataclasses import dataclass
from functools import partial
from io import BytesIO
from typing import Any, Callable, ClassVar
from typing import Any, ClassVar

import param

Expand Down
3 changes: 2 additions & 1 deletion panel/chat/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

import datetime

from collections.abc import Callable
from contextlib import ExitStack
from dataclasses import dataclass
from functools import partial
from io import BytesIO
from tempfile import NamedTemporaryFile
from typing import (
TYPE_CHECKING, Any, Callable, ClassVar, Union,
TYPE_CHECKING, Any, ClassVar, Union,
)
from zoneinfo import ZoneInfo

Expand Down
3 changes: 2 additions & 1 deletion panel/chat/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import traceback

from typing import ClassVar, Literal, Mapping
from collections.abc import Mapping
from typing import ClassVar, Literal

import param

Expand Down
3 changes: 2 additions & 1 deletion panel/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import textwrap

from collections import defaultdict
from collections.abc import Callable, Mapping
from functools import partial
from typing import (
TYPE_CHECKING, Any, Callable, ClassVar, Literal, Mapping,
TYPE_CHECKING, Any, ClassVar, Literal,
)

import param
Expand Down
2 changes: 1 addition & 1 deletion panel/entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import importlib.metadata

from typing import Iterator
from collections.abc import Iterator


def entry_points_for(group: str) -> Iterator[importlib.metadata.EntryPoint]:
Expand Down
5 changes: 2 additions & 3 deletions panel/io/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
import logging
import os

from collections.abc import Callable, Sequence
from functools import partial
from types import FunctionType, MethodType
from typing import (
TYPE_CHECKING, Any, Callable, Sequence, TypeAlias,
)
from typing import TYPE_CHECKING, Any, TypeAlias
from urllib.parse import urljoin

import bokeh.command.util
Expand Down
3 changes: 2 additions & 1 deletion panel/io/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"""
from __future__ import annotations

from typing import TYPE_CHECKING, ClassVar, Mapping
from collections.abc import Mapping
from typing import TYPE_CHECKING, ClassVar

import param # type: ignore

Expand Down
4 changes: 2 additions & 2 deletions panel/io/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import time
import unittest.mock

from collections.abc import Awaitable, Callable, Hashable
from contextlib import contextmanager
from typing import (
TYPE_CHECKING, Any, Awaitable, Callable, Hashable, Literal, ParamSpec,
Protocol, TypeVar, cast, overload,
TYPE_CHECKING, Any, Literal, ParamSpec, Protocol, TypeVar, cast, overload,
)

import param
Expand Down
2 changes: 1 addition & 1 deletion panel/io/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def setup_build_dir(build_dir: str | os.PathLike | None = None):

def check_cli_tool(tool_name):
try:
result = subprocess.run([tool_name, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = subprocess.run([tool_name, '--version'], capture_output=True)
if result.returncode == 0:
return True
else:
Expand Down
5 changes: 2 additions & 3 deletions panel/io/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import pathlib
import uuid

from typing import (
IO, Any, Literal, Sequence,
)
from collections.abc import Sequence
from typing import IO, Any, Literal

import bokeh

Expand Down
5 changes: 2 additions & 3 deletions panel/io/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
import time
import weakref

from collections.abc import Callable, Iterator, Sequence
from contextlib import contextmanager
from functools import partial, wraps
from typing import (
TYPE_CHECKING, Any, Callable, Iterator, Sequence,
)
from typing import TYPE_CHECKING, Any
from weakref import WeakKeyDictionary

from bokeh.application.application import SessionContext
Expand Down
5 changes: 2 additions & 3 deletions panel/io/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
import traceback
import urllib.parse as urlparse

from collections.abc import Callable, Iterator
from contextlib import contextmanager
from types import ModuleType
from typing import (
IO, TYPE_CHECKING, Any, Callable, Iterator,
)
from typing import IO, TYPE_CHECKING, Any

import bokeh.command.util

Expand Down
3 changes: 2 additions & 1 deletion panel/io/jupyter_server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
import textwrap
import time

from collections.abc import Awaitable
from queue import Empty
from typing import Any, Awaitable
from typing import Any
from urllib.parse import urljoin

import tornado
Expand Down
5 changes: 2 additions & 3 deletions panel/io/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import json
import urllib.parse as urlparse

from typing import (
TYPE_CHECKING, Any, Callable, ClassVar, Mapping,
)
from collections.abc import Callable, Mapping
from typing import TYPE_CHECKING, Any, ClassVar

import param

Expand Down
5 changes: 2 additions & 3 deletions panel/io/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

import textwrap

from collections.abc import Iterable, Sequence
from contextlib import contextmanager
from typing import (
TYPE_CHECKING, Any, Iterable, Sequence,
)
from typing import TYPE_CHECKING, Any

import numpy as np

Expand Down
5 changes: 2 additions & 3 deletions panel/io/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
import uuid
import warnings

from collections.abc import Iterator
from contextlib import contextmanager
from functools import partial
from typing import (
TYPE_CHECKING, Any, Iterator, Literal,
)
from typing import TYPE_CHECKING, Any, Literal

import bokeh
import bokeh.embed.notebook
Expand Down
3 changes: 2 additions & 1 deletion panel/io/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import tempfile
import uuid

from collections.abc import Callable, Iterator, Sequence
from contextlib import contextmanager
from cProfile import Profile
from functools import wraps
from typing import (
TYPE_CHECKING, Callable, Iterator, Literal, ParamSpec, Sequence, TypeVar,
TYPE_CHECKING, Literal, ParamSpec, TypeVar,
)

from ..config import config
Expand Down
3 changes: 2 additions & 1 deletion panel/io/pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import sys
import uuid

from typing import TYPE_CHECKING, Any, Callable
from collections.abc import Callable
from typing import TYPE_CHECKING, Any

import bokeh
import js
Expand Down
5 changes: 2 additions & 3 deletions panel/io/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import io
import os

from typing import (
IO, TYPE_CHECKING, Any, Iterable,
)
from collections.abc import Iterable
from typing import IO, TYPE_CHECKING, Any

import bokeh

Expand Down
5 changes: 2 additions & 3 deletions panel/io/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
import sys
import uuid

from collections.abc import Callable, Mapping
from functools import partial, wraps
from html import escape
from typing import (
TYPE_CHECKING, Any, Callable, Mapping, TypedDict,
)
from typing import TYPE_CHECKING, Any, TypedDict
from urllib.parse import urlparse

import bokeh
Expand Down
9 changes: 5 additions & 4 deletions panel/io/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
import time

from collections import Counter, defaultdict
from collections.abc import Iterator
from collections.abc import (
Callable, Coroutine, Hashable, Iterator, Iterator as TIterator,
)
from contextlib import contextmanager, suppress
from contextvars import ContextVar
from functools import partial, wraps
from typing import (
TYPE_CHECKING, Any, Callable, ClassVar, Coroutine, Hashable,
Iterator as TIterator, Literal, TypeVar, Union,
TYPE_CHECKING, Any, ClassVar, Literal, TypeAlias, TypeVar,
)
from urllib.parse import urljoin
from weakref import WeakKeyDictionary
Expand Down Expand Up @@ -89,7 +90,7 @@ def curdoc_locked() -> Document | None:

class _Undefined: pass

Tat = Union[dt.datetime, Callable[[dt.datetime], dt.datetime], TIterator[dt.datetime]]
Tat: TypeAlias = dt.datetime | Callable[[dt.datetime], dt.datetime], TIterator[dt.datetime]

class _state(param.Parameterized):
"""
Expand Down
5 changes: 2 additions & 3 deletions panel/layout/accordion.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

from typing import (
TYPE_CHECKING, Callable, ClassVar, Mapping,
)
from collections.abc import Callable, Mapping
from typing import TYPE_CHECKING, ClassVar

import param

Expand Down
5 changes: 3 additions & 2 deletions panel/layout/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
from __future__ import annotations

from collections import defaultdict, namedtuple
from typing import (
TYPE_CHECKING, Any, ClassVar, Generator, Iterable, Iterator, Mapping,
from collections.abc import (
Generator, Iterable, Iterator, Mapping,
)
from typing import TYPE_CHECKING, Any, ClassVar

import param

Expand Down
5 changes: 2 additions & 3 deletions panel/layout/card.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

from typing import (
TYPE_CHECKING, Callable, ClassVar, Mapping,
)
from collections.abc import Callable, Mapping
from typing import TYPE_CHECKING, ClassVar

import param

Expand Down
3 changes: 2 additions & 1 deletion panel/layout/feed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING, ClassVar, Mapping
from collections.abc import Mapping
from typing import TYPE_CHECKING, ClassVar

import param

Expand Down
5 changes: 2 additions & 3 deletions panel/layout/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
import math

from collections import namedtuple
from collections.abc import Mapping
from functools import partial
from typing import (
TYPE_CHECKING, Any, ClassVar, Mapping,
)
from typing import TYPE_CHECKING, Any, ClassVar

import numpy as np
import param
Expand Down
3 changes: 2 additions & 1 deletion panel/layout/gridstack.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import ClassVar, Mapping
from collections.abc import Mapping
from typing import ClassVar

import param

Expand Down
3 changes: 2 additions & 1 deletion panel/layout/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from __future__ import annotations

from collections import defaultdict
from typing import TYPE_CHECKING, ClassVar, Mapping
from collections.abc import Mapping
from typing import TYPE_CHECKING, ClassVar

import param

Expand Down
5 changes: 2 additions & 3 deletions panel/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import sys
import weakref

from typing import (
TYPE_CHECKING, Any, Iterable, Sequence, TypeAlias,
)
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Any, TypeAlias

import param

Expand Down
3 changes: 2 additions & 1 deletion panel/pane/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"""
from __future__ import annotations

from typing import Any, ClassVar, Mapping
from collections.abc import Mapping
from typing import Any, ClassVar

import param

Expand Down
Loading

0 comments on commit b865a10

Please sign in to comment.