Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid circular imports #334

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions khard/carddav_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@
import sys
import time
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, \
TypeVar, Union, Sequence, overload
TYPE_CHECKING, TypeVar, Union, Sequence, overload

from atomicwrites import atomic_write
from ruamel import yaml
from ruamel.yaml import YAML
import vobject

from . import address_book # pylint: disable=unused-import # for type checking
from . import helpers
from .helpers.typing import (Date, ObjectType, PostAddress, StrList,
convert_to_vcard, list_to_string, string_to_date,
string_to_list)
from .query import AnyQuery, Query

if TYPE_CHECKING:
from . import address_book


logger = logging.getLogger(__name__)
T = TypeVar("T")
Expand Down
7 changes: 5 additions & 2 deletions khard/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
from functools import reduce
from operator import and_, or_
import re
from typing import cast, Any, Dict, List, Optional, Union
from typing import cast, Any, Dict, List, Optional, TYPE_CHECKING, Union

from . import carddav_object
if TYPE_CHECKING:
from . import carddav_object

# constants
FIELD_PHONE_NUMBERS = "phone_numbers"
Expand Down Expand Up @@ -342,6 +343,8 @@ def parse(string: str) -> Union[TermQuery, FieldQuery]:
:returns: a FieldQuery if the string contains a valid field specifier, a
TermQuery otherwise
"""
from . import carddav_object

if ":" in string:
field, term = string.split(":", maxsplit=1)
if field == "name":
Expand Down
Loading