Skip to content

Commit

Permalink
use typing_extensions only in <py3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
sim0nx committed Dec 19, 2023
1 parent b3fe6e6 commit 96782ba
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
5 changes: 3 additions & 2 deletions caldav/davclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from urllib.parse import unquote

import requests
import typing_extensions
from caldav.elements import dav
from caldav.lib import error
from caldav.lib.python_utilities import to_normal_str
Expand All @@ -32,8 +31,10 @@

if sys.version_info < (3, 9):
from typing import Iterable, Mapping
from typing_extensions import Self
else:
from collections.abc import Iterable, Mapping
from typing import Self


class DAVResponse:
Expand Down Expand Up @@ -434,7 +435,7 @@ def __init__(

self._principal = None

def __enter__(self) -> typing_extensions.Self:
def __enter__(self) -> Self:
return self

def __exit__(
Expand Down
7 changes: 5 additions & 2 deletions caldav/elements/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
from caldav.lib.python_utilities import to_unicode
from lxml import etree
from lxml.etree import _Element
from typing_extensions import Self
from typing_extensions import TypeAlias


if sys.version_info < (3, 9):
from typing import Iterable
from typing_extensions import Self
from typing_extensions import TypeAlias
else:
from collections.abc import Iterable
from typing import Self
from typing import TypeAlias


class BaseElement:
Expand Down
7 changes: 6 additions & 1 deletion caldav/lib/url.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
import typing
import urllib.parse
from typing import Union
Expand All @@ -12,7 +13,11 @@

from caldav.lib.python_utilities import to_normal_str
from caldav.lib.python_utilities import to_unicode
from typing_extensions import Self

if sys.version_info < (3, 9):
from typing_extensions import Self
else:
from typing import Self


class URL:
Expand Down
6 changes: 4 additions & 2 deletions caldav/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class hierarchy into a separate file)
from dateutil.rrule import rrulestr
from lxml import etree
from lxml.etree import _Element
from typing_extensions import Literal
from typing_extensions import Self
from vobject.base import VBase

from .elements.base import BaseElement
Expand Down Expand Up @@ -66,13 +64,17 @@ class hierarchy into a separate file)
from typing import Callable, Container, Iterator, Sequence
from typing import Iterable
from typing_extensions import DefaultDict
from typing_extensions import Literal
from typing_extensions import Self
else:
from collections.abc import Callable
from collections.abc import Container
from collections.abc import Iterable
from collections.abc import Iterator
from collections.abc import Sequence
from collections import defaultdict as DefaultDict
from typing import Literal
from typing import Self

_CC = TypeVar("_CC", bound="CalendarObjectResource")
log = logging.getLogger("caldav")
Expand Down

0 comments on commit 96782ba

Please sign in to comment.