Skip to content

Commit

Permalink
enhance: upgrade ruff and coding styles (#1914)
Browse files Browse the repository at this point in the history
Signed-off-by: yangxuan <[email protected]>
  • Loading branch information
XuanYang-cn authored Feb 5, 2024
1 parent 3595c90 commit de1bcad
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pymilvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,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

Expand Down
4 changes: 2 additions & 2 deletions pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,10 @@ def search_requests_with_expr(
raise ParamError(message=f"wrong type for offset, expect int, got {type(offset)}")
search_params["offset"] = offset

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 param.get(GROUP_BY_FIELD, None) is not None:
if param.get(GROUP_BY_FIELD) is not None:
search_params[GROUP_BY_FIELD] = param[GROUP_BY_FIELD]

if anns_field:
Expand Down
2 changes: 1 addition & 1 deletion pymilvus/client/ts_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pymilvus/orm/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,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(
Expand Down
4 changes: 2 additions & 2 deletions pymilvus/orm/iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions pymilvus/orm/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,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):
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extend-exclude = '''
'''

[tool.ruff]
select = [
lint.select = [
"E",
"F",
"C90",
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pytest-cov>=2.8.1
pytest-timeout>=1.3.4
grpcio-testing==1.60.0
sklearn==0.0
ruff
ruff>=0.2.0
black

0 comments on commit de1bcad

Please sign in to comment.