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

fix: Coding style by latest ruff #2158

Merged
merged 1 commit into from
Jul 2, 2024
Merged
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
14 changes: 3 additions & 11 deletions pymilvus/client/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@ def is_legal_address(addr: Any) -> bool:
if len(a) != 2:
return False

if not is_legal_host(a[0]) or not is_legal_port(a[1]):
return False

return True
return is_legal_host(a[0]) and is_legal_port(a[1])


def is_legal_host(host: Any) -> bool:
if not isinstance(host, str) or len(host) == 0 or (":" in host):
return False

return True
return isinstance(host, str) and len(host) > 0 and (":" not in host)


def is_legal_port(port: Any) -> bool:
Expand Down Expand Up @@ -163,10 +157,8 @@ def parser_range_date(date: Union[str, datetime.date]) -> str:
def is_legal_date_range(start: str, end: str) -> bool:
start_date = datetime.datetime.strptime(start, "%Y-%m-%d")
end_date = datetime.datetime.strptime(end, "%Y-%m-%d")
if (end_date - start_date).days < 0:
return False

return True
return (end_date - start_date).days >= 0


def is_legal_partition_name(tag: Any) -> bool:
Expand Down
1 change: 0 additions & 1 deletion pymilvus/client/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ class MetricType(IntEnum):
HAMMING = 3
JACCARD = 4
TANIMOTO = 5
#
SUBSTRUCTURE = 6
SUPERSTRUCTURE = 7

Expand Down
7 changes: 4 additions & 3 deletions pymilvus/orm/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1438,9 +1438,10 @@ def has_index(self, timeout: Optional[float] = None, **kwargs) -> bool:
conn = self._get_connection()
copy_kwargs = copy.deepcopy(kwargs)
index_name = copy_kwargs.pop("index_name", Config.IndexName)
if conn.describe_index(self._name, index_name, timeout=timeout, **copy_kwargs) is None:
return False
return True

return (
conn.describe_index(self._name, index_name, timeout=timeout, **copy_kwargs) is not None
)

def drop_index(self, timeout: Optional[float] = None, **kwargs):
"""Drop index and its corresponding index files.
Expand Down
4 changes: 1 addition & 3 deletions pymilvus/orm/iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,7 @@ def __update_filtered_ids(self, res: SearchPage):

def __is_cache_enough(self, count: int) -> bool:
cached_page = iterator_cache.fetch_cache(self._cache_id)
if cached_page is None or len(cached_page) < count:
return False
return True
return cached_page is not None and len(cached_page) >= count

def __extract_page_from_cache(self, count: int) -> SearchPage:
cached_page = iterator_cache.fetch_cache(self._cache_id)
Expand Down