Skip to content

Commit

Permalink
fix: Coding style by latest ruff (#2159)
Browse files Browse the repository at this point in the history
Signed-off-by: yangxuan <[email protected]>
  • Loading branch information
XuanYang-cn authored Jul 2, 2024
1 parent 99ad63e commit a5281f3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
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

0 comments on commit a5281f3

Please sign in to comment.