diff --git a/pymilvus/client/grpc_handler.py b/pymilvus/client/grpc_handler.py index 8190cfc7f..9f9931e6d 100644 --- a/pymilvus/client/grpc_handler.py +++ b/pymilvus/client/grpc_handler.py @@ -1002,7 +1002,7 @@ def describe_index( info_dict = {kv.key: kv.value for kv in response.index_descriptions[0].params} info_dict["field_name"] = response.index_descriptions[0].field_name info_dict["index_name"] = response.index_descriptions[0].index_name - if info_dict.get("params", None): + if info_dict.get("params"): info_dict["params"] = json.loads(info_dict["params"]) return info_dict diff --git a/pymilvus/client/prepare.py b/pymilvus/client/prepare.py index 7ee4d1946..b5789ff1b 100644 --- a/pymilvus/client/prepare.py +++ b/pymilvus/client/prepare.py @@ -626,7 +626,7 @@ def search_requests_with_expr( if group_by_field is not None: search_params[GROUP_BY_FIELD] = group_by_field - if param.get("metric_type", None) is not None: + if param.get("metric_type") is not None: search_params["metric_type"] = param["metric_type"] if anns_field: diff --git a/pymilvus/client/ts_utils.py b/pymilvus/client/ts_utils.py index 46d72e365..c260aa4a8 100644 --- a/pymilvus/client/ts_utils.py +++ b/pymilvus/client/ts_utils.py @@ -75,7 +75,7 @@ def get_bounded_ts(): def construct_guarantee_ts(collection_name: str, kwargs: Dict): - consistency_level = kwargs.get("consistency_level", None) + consistency_level = kwargs.get("consistency_level") use_default = consistency_level is None if use_default: # in case of the default consistency is Customized or Session, diff --git a/pymilvus/orm/collection.py b/pymilvus/orm/collection.py index d152484b2..85d306b32 100644 --- a/pymilvus/orm/collection.py +++ b/pymilvus/orm/collection.py @@ -1260,7 +1260,7 @@ def indexes(self, **kwargs) -> List[Index]: for index in tmp_index: if index is not None: info_dict = {kv.key: kv.value for kv in index.params} - if info_dict.get("params", None): + if info_dict.get("params"): info_dict["params"] = json.loads(info_dict["params"]) index_info = Index( diff --git a/pymilvus/orm/iterator.py b/pymilvus/orm/iterator.py index 50db692b4..5cad24dfe 100644 --- a/pymilvus/orm/iterator.py +++ b/pymilvus/orm/iterator.py @@ -176,7 +176,7 @@ def __check_reached_limit(self, ret: List): def __setup__pk_prop(self): fields = self._schema[FIELDS] for field in fields: - if IS_PRIMARY in field and field[IS_PRIMARY]: + if field.get(IS_PRIMARY): if field["type"] == DataType.VARCHAR: self._pk_str = True else: @@ -383,7 +383,7 @@ def __check_for_special_index_param(self): def __setup__pk_prop(self): fields = self._schema[FIELDS] for field in fields: - if IS_PRIMARY in field and field[IS_PRIMARY]: + if field.get(IS_PRIMARY): if field["type"] == DataType.VARCHAR: self._pk_str = True else: diff --git a/pymilvus/orm/schema.py b/pymilvus/orm/schema.py index 142340e5b..f92598888 100644 --- a/pymilvus/orm/schema.py +++ b/pymilvus/orm/schema.py @@ -309,11 +309,11 @@ def construct_from_dict(cls, raw: Dict): kwargs = {} kwargs.update(raw.get("params", {})) kwargs["is_primary"] = raw.get("is_primary", False) - if raw.get("auto_id", None) is not None: - kwargs["auto_id"] = raw.get("auto_id", None) + if raw.get("auto_id") is not None: + kwargs["auto_id"] = raw.get("auto_id") kwargs["is_partition_key"] = raw.get("is_partition_key", False) kwargs["is_dynamic"] = raw.get("is_dynamic", False) - kwargs["element_type"] = raw.get("element_type", None) + kwargs["element_type"] = raw.get("element_type") return FieldSchema(raw["name"], raw["type"], raw.get("description", ""), **kwargs) def to_dict(self): diff --git a/pyproject.toml b/pyproject.toml index 643d64c67..903907b18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,7 +61,7 @@ extend-exclude = ''' ''' [tool.ruff] -select = [ +lint.select = [ "E", "F", "C90", @@ -72,7 +72,7 @@ select = [ "ANN001", "S", "T", "W", "ARG", "BLE", "COM", "DJ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT" ] -ignore = [ +lint.ignore = [ "N818", "DTZ", # datatime related "BLE", # blind-except (BLE001) @@ -100,14 +100,14 @@ ignore = [ ] # Allow autofix for all enabled rules (when `--fix`) is provided. -fixable = [ +lint.fixable = [ "A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT", ] -unfixable = [] +lint.unfixable = [] show-fixes = true @@ -144,23 +144,23 @@ exclude = [ line-length = 100 # Allow unused variables when underscore-prefixed. -dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" +lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" # Assume Python 3.7 target-version = "py37" -[tool.ruff.mccabe] +[tool.ruff.lint.mccabe] # Unlike Flake8, default to a complexity level of 10. max-complexity = 18 -[tool.ruff.pycodestyle] +[tool.ruff.lint.pycodestyle] max-doc-length = 100 -[tool.ruff.pylint] +[tool.ruff.lint.pylint] max-args = 20 max-branches = 15 -[tool.ruff.flake8-builtins] +[tool.ruff.lint.flake8-builtins] builtins-ignorelist = [ "format", "next", diff --git a/requirements.txt b/requirements.txt index 42d9ab726..a910ad867 100644 --- a/requirements.txt +++ b/requirements.txt @@ -33,7 +33,7 @@ pytest>=5.3.4 pytest-cov>=2.8.1 pytest-timeout>=1.3.4 pandas>=1.1.5 -ruff +ruff>=0.2.0 black requests minio diff --git a/test_requirements.txt b/test_requirements.txt index a7fe4e2fa..870364987 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -3,7 +3,7 @@ pytest-cov>=2.8.1 pytest-timeout>=1.3.4 grpcio-testing==1.60.0 sklearn==0.0 -ruff +ruff>=0.2.0 black tensorflow;python_version <'3.12' # for python3.12 support