This is an automated email from the ASF dual-hosted git repository.
jin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git
The following commit(s) were added to refs/heads/main by this push:
new 815dac5 feat: introduce pylint for code analysis (#22)
815dac5 is described below
commit 815dac518729f780b9267b263d6cdac4350a8790
Author: Simon Cheung <[email protected]>
AuthorDate: Mon Oct 23 18:08:40 2023 +0800
feat: introduce pylint for code analysis (#22)
---
.github/workflows/pylint.yml | 7 +-
hugegraph-llm/examples/build_kg_test.py | 42 +-
hugegraph-llm/requirements.txt | 3 +
hugegraph-llm/src/hugegraph_llm/llms/base.py | 2 +
hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py | 10 +-
.../hugegraph_llm/operators/build_kg_operator.py | 14 +-
.../operators/hugegraph_op/commit_data_to_kg.py | 30 +-
.../operators/llm_op/disambiguate_data.py | 20 +-
.../operators/llm_op/parse_text_to_data.py | 23 +-
.../operators/llm_op/unstructured_data_utils.py | 31 +-
hugegraph-python-client/example/client_test.py | 23 -
hugegraph-python-client/example/hugegraph_test.py | 5 +-
hugegraph-python-client/example/test.py | 8 +-
.../src/pyhugegraph/api/common.py | 10 +-
.../src/pyhugegraph/api/graph.py | 243 +++++---
.../src/pyhugegraph/api/graphs.py | 19 +-
.../src/pyhugegraph/api/gremlin.py | 7 +-
.../src/pyhugegraph/api/schema.py | 31 +-
.../pyhugegraph/api/schema_manage/edge_label.py | 81 ++-
.../pyhugegraph/api/schema_manage/index_label.py | 24 +-
.../pyhugegraph/api/schema_manage/property_key.py | 76 +--
.../pyhugegraph/api/schema_manage/vertex_label.py | 72 ++-
.../src/pyhugegraph/structure/edge_data.py | 2 +-
.../src/pyhugegraph/structure/edge_label_data.py | 7 +-
.../src/pyhugegraph/structure/graph_instance.py | 5 +-
.../src/pyhugegraph/structure/index_label_data.py | 7 +-
.../src/pyhugegraph/structure/property_key_data.py | 4 +-
.../src/pyhugegraph/structure/respon_data.py | 2 +-
.../src/pyhugegraph/structure/vertex_data.py | 2 +-
.../src/pyhugegraph/structure/vertex_label_data.py | 6 +-
.../src/pyhugegraph/utils/exceptions.py | 18 +-
.../src/pyhugegraph/utils/huge_decorator.py | 10 +-
.../src/pyhugegraph/utils/huge_requests.py | 4 +-
.../src/pyhugegraph/utils/util.py | 17 +-
pylint.conf | 647 +++++++++++++++++++++
35 files changed, 1136 insertions(+), 376 deletions(-)
diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml
index 7566659..ccb4613 100644
--- a/.github/workflows/pylint.yml
+++ b/.github/workflows/pylint.yml
@@ -22,6 +22,11 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pylint
+ pip install -r ./hugegraph-llm/requirements.txt
+ pip install -r ./hugegraph-python-client/requirements.txt
- name: Analysing the code with pylint
run: |
- pylint $(git ls-files '*.py')
+ export
PYTHONPATH=$(pwd)/hugegraph-llm/src:$(pwd)/hugegraph-python-client/src
+ echo ${PYTHONPATH}
+ pylint --rcfile=./pylint.conf hugegraph-llm
+ pylint --rcfile=./pylint.conf hugegraph-python-client
diff --git a/hugegraph-llm/examples/build_kg_test.py
b/hugegraph-llm/examples/build_kg_test.py
index e1bdfb3..ece0048 100644
--- a/hugegraph-llm/examples/build_kg_test.py
+++ b/hugegraph-llm/examples/build_kg_test.py
@@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+
import os
from hugegraph_llm.operators.build_kg_operator import KgBuilder
from hugegraph_llm.llms.openai_llm import OpenAIChat
@@ -22,28 +24,35 @@ if __name__ == "__main__":
# If you need a proxy to access OpenAI's API, please set your HTTP proxy
here
os.environ["http_proxy"] = ""
os.environ["https_proxy"] = ""
- api_key = ""
+ API_KEY = ""
default_llm = OpenAIChat(
- api_key=api_key, model_name="gpt-3.5-turbo-16k", max_tokens=4000
+ api_key=API_KEY,
+ model_name="gpt-3.5-turbo-16k",
+ max_tokens=4000,
)
- text = (
- "Meet Sarah, a 30-year-old attorney, and her roommate, James, whom
she's shared a home with since 2010. James, "
- "in his professional life, works as a journalist. Additionally, Sarah
is the proud owner of the website "
- "www.sarahsplace.com, while James manages his own webpage, though the
specific URL is not mentioned here. "
- "These two individuals, Sarah and James, have not only forged a strong
personal bond as roommates but have "
- "also carved out their distinctive digital presence through their
respective webpages, showcasing their "
- "varied interests and experiences."
+ TEXT = (
+ "Meet Sarah, a 30-year-old attorney, and her roommate, James, whom
she's shared a home with"
+ " since 2010. James, in his professional life, works as a journalist.
Additionally, Sarah"
+ " is the proud owner of the website www.sarahsplace.com, while James
manages his own"
+ " webpage, though the specific URL is not mentioned here. These two
individuals, Sarah and"
+ " James, have not only forged a strong personal bond as roommates but
have also carved out"
+ " their distinctive digital presence through their respective
webpages, showcasing their"
+ " varied interests and experiences."
)
builder = KgBuilder(default_llm)
# build kg with only text
-
builder.parse_text_to_data(text).disambiguate_data().commit_data_to_kg().run()
+
builder.parse_text_to_data(TEXT).disambiguate_data().commit_data_to_kg().run()
# build kg with text and schemas
nodes_schemas = [
{
"label": "Person",
"primary_key": "name",
- "properties": {"age": "int", "name": "text", "occupation": "text"},
+ "properties": {
+ "age": "int",
+ "name": "text",
+ "occupation": "text",
+ },
},
{
"label": "Webpage",
@@ -58,12 +67,15 @@ if __name__ == "__main__":
"type": "roommate",
"properties": {"start": "int"},
},
- {"start": "Person", "end": "Webpage", "type": "owns", "properties":
{}},
+ {
+ "start": "Person",
+ "end": "Webpage",
+ "type": "owns",
+ "properties": {},
+ },
]
(
- builder.parse_text_to_data_with_schemas(
- text, nodes_schemas, relationships_schemas
- )
+ builder.parse_text_to_data_with_schemas(TEXT, nodes_schemas,
relationships_schemas)
.disambiguate_data_with_schemas()
.commit_data_to_kg()
.run()
diff --git a/hugegraph-llm/requirements.txt b/hugegraph-llm/requirements.txt
new file mode 100644
index 0000000..5341b0b
--- /dev/null
+++ b/hugegraph-llm/requirements.txt
@@ -0,0 +1,3 @@
+openai==0.28.1
+retry==0.9.2
+tiktoken==0.5.1
diff --git a/hugegraph-llm/src/hugegraph_llm/llms/base.py
b/hugegraph-llm/src/hugegraph_llm/llms/base.py
index 1ff2923..a9a1bdb 100644
--- a/hugegraph-llm/src/hugegraph_llm/llms/base.py
+++ b/hugegraph-llm/src/hugegraph_llm/llms/base.py
@@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+
from abc import ABC, abstractmethod
from typing import Any, List, Optional, Callable
diff --git a/hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py
b/hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py
index ded7f34..7766abf 100644
--- a/hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py
+++ b/hugegraph-llm/src/hugegraph_llm/llms/openai_llm.py
@@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+
from typing import Callable, List, Optional
import openai
import tiktoken
@@ -56,10 +58,10 @@ class OpenAIChat(BaseLLM):
return str(f"Error: {e}")
# catch authorization errors / do not retry
except openai.error.AuthenticationError as e:
- return "Error: The provided OpenAI API key is invalid"
+ return f"Error: The provided OpenAI API key is invalid, {e}"
except Exception as e:
print(f"Retrying LLM call {e}")
- raise Exception()
+ raise Exception() from e
async def generate_streaming(
self,
@@ -86,11 +88,11 @@ class OpenAIChat(BaseLLM):
await on_token_callback(message)
return result
- def num_tokens_from_string(self, string: str) -> int:
+ async def num_tokens_from_string(self, string: str) -> int:
encoding = tiktoken.encoding_for_model(self.model)
num_tokens = len(encoding.encode(string))
return num_tokens
- def max_allowed_token_length(self) -> int:
+ async def max_allowed_token_length(self) -> int:
# TODO: list all models and their max tokens from api
return 2049
diff --git a/hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py
b/hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py
index ee0d154..deb7a2b 100644
--- a/hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py
+++ b/hugegraph-llm/src/hugegraph_llm/operators/build_kg_operator.py
@@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+
from hugegraph_llm.operators.hugegraph_op.commit_data_to_kg import
CommitDataToKg
from hugegraph_llm.operators.llm_op.disambiguate_data import DisambiguateData
from hugegraph_llm.operators.llm_op.parse_text_to_data import (
@@ -33,9 +35,7 @@ class KgBuilder:
self.parse_text_to_kg.append(ParseTextToData(llm=self.llm, text=text))
return self
- def parse_text_to_data_with_schemas(
- self, text: str, nodes_schemas, relationships_schemas
- ):
+ def parse_text_to_data_with_schemas(self, text: str, nodes_schemas,
relationships_schemas):
self.parse_text_to_kg.append(
ParseTextToDataWithSchemas(
llm=self.llm,
@@ -47,15 +47,11 @@ class KgBuilder:
return self
def disambiguate_data(self):
- self.parse_text_to_kg.append(
- DisambiguateData(llm=self.llm, is_user_schema=False)
- )
+ self.parse_text_to_kg.append(DisambiguateData(llm=self.llm,
is_user_schema=False))
return self
def disambiguate_data_with_schemas(self):
- self.parse_text_to_kg.append(
- DisambiguateData(llm=self.llm, is_user_schema=True)
- )
+ self.parse_text_to_kg.append(DisambiguateData(llm=self.llm,
is_user_schema=True))
return self
def commit_data_to_kg(self):
diff --git
a/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py
b/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py
index 7d1c929..6d6764b 100644
---
a/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py
+++
b/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/commit_data_to_kg.py
@@ -14,22 +14,23 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+
import os
from pyhugegraph.client import PyHugeClient
def generate_new_relationships(nodes_schemas_data, relationships_data):
- label_id = dict()
+ label_id = {}
i = 1
old_label = []
for item in nodes_schemas_data:
label = item["label"]
if label in old_label:
continue
- else:
- label_id[label] = i
- i += 1
- old_label.append(label)
+ label_id[label] = i
+ i += 1
+ old_label.append(label)
new_relationships_data = []
for relationship in relationships_data:
start = relationship["start"]
@@ -45,7 +46,7 @@ def generate_new_relationships(nodes_schemas_data,
relationships_data):
for key1, value1 in end.items():
if key1 == key:
new_end = f"{value}" + ":" + f"{value1}"
- relationships_data = dict()
+ relationships_data = {}
relationships_data["start"] = new_start
relationships_data["end"] = new_end
relationships_data["type"] = relationships_type
@@ -91,7 +92,7 @@ def generate_schema_nodes(data):
properties = item["properties"]
schema_statement = f"schema.vertexLabel('{label}').properties("
schema_statement += ", ".join(f"'{prop}'" for prop in
properties.keys())
- schema_statement += f").nullableKeys("
+ schema_statement += ").nullableKeys("
schema_statement += ", ".join(
f"'{prop}'" for prop in properties.keys() if prop != primary_key
)
@@ -109,11 +110,14 @@ def generate_schema_relationships(data):
end = item["end"]
schema_relationships_type = item["type"]
properties = item["properties"]
- schema_statement =
f"schema.edgeLabel('{schema_relationships_type}').sourceLabel('{start}').targetLabel('{end}').properties("
+ schema_statement = (
+ f"schema.edgeLabel('{schema_relationships_type}')"
+ f".sourceLabel('{start}').targetLabel('{end}').properties("
+ )
schema_statement += ", ".join(f"'{prop}'" for prop in
properties.keys())
- schema_statement += f").nullableKeys("
+ schema_statement += ").nullableKeys("
schema_statement += ", ".join(f"'{prop}'" for prop in
properties.keys())
- schema_statement += f").ifNotExist().create()"
+ schema_statement += ").ifNotExist().create()"
schema_relationships_statements.append(schema_statement)
return schema_relationships_statements
@@ -153,12 +157,9 @@ class CommitDataToKg:
relationships = data["relationships"]
nodes_schemas = data["nodes_schemas"]
relationships_schemas = data["relationships_schemas"]
- schema = self.schema
# properties schema
schema_nodes_properties = generate_schema_properties(nodes_schemas)
- schema_relationships_properties = generate_schema_properties(
- relationships_schemas
- )
+ schema_relationships_properties =
generate_schema_properties(relationships_schemas)
for schema_nodes_property in schema_nodes_properties:
exec(schema_nodes_property)
@@ -175,7 +176,6 @@ class CommitDataToKg:
for schema_relationship in schema_relationships:
exec(schema_relationship)
- g = self.client.graph()
# nodes
nodes = generate_nodes(nodes)
for node in nodes:
diff --git
a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py
b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py
index e982d99..f540673 100644
--- a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py
+++ b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/disambiguate_data.py
@@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+
import json
import re
from itertools import groupby
@@ -102,7 +104,7 @@ def generate_prompt(data) -> str:
"""
-internalRegex = r"\[(.*?)\]"
+INTERNAL_REGEX = r"\[(.*?)\]"
class DisambiguateData:
@@ -144,7 +146,7 @@ class DisambiguateData:
{"role": "user", "content": generate_prompt(dis_string)},
]
raw_nodes = self.llm.generate(messages)
- n = re.findall(internalRegex, raw_nodes)
+ n = re.findall(INTERNAL_REGEX, raw_nodes)
new_nodes.extend(nodes_text_to_list_of_dict(n))
relationship_data = ""
@@ -172,7 +174,7 @@ class DisambiguateData:
{"role": "user", "content": generate_prompt(relationship_data)},
]
raw_relationships = self.llm.generate(messages)
- rels = re.findall(internalRegex, raw_relationships)
+ rels = re.findall(INTERNAL_REGEX, raw_relationships)
new_relationships.extend(relationships_text_to_list_of_dict(rels))
if not self.is_user_schema:
@@ -193,7 +195,7 @@ class DisambiguateData:
{"role": "user", "content":
generate_prompt(nodes_schemas_data)},
]
raw_nodes_schemas = self.llm.generate(messages)
- n = re.findall(internalRegex, raw_nodes_schemas)
+ n = re.findall(INTERNAL_REGEX, raw_nodes_schemas)
new_nodes_schemas.extend(nodes_schemas_text_to_list_of_dict(n))
relationships_schemas_data = ""
@@ -210,12 +212,8 @@ class DisambiguateData:
+ "]\n"
)
- node_schemas_labels = [
- nodes_schemas["label"] for nodes_schemas in new_nodes_schemas
- ]
- relationships_schemas_data += "Valid Labels:\n" + "\n".join(
- node_schemas_labels
- )
+ node_schemas_labels = [nodes_schemas["label"] for nodes_schemas in
new_nodes_schemas]
+ relationships_schemas_data += "Valid Labels:\n" +
"\n".join(node_schemas_labels)
messages = [
{
@@ -228,7 +226,7 @@ class DisambiguateData:
},
]
raw_relationships_schemas = self.llm.generate(messages)
- schemas_rels = re.findall(internalRegex, raw_relationships_schemas)
+ schemas_rels = re.findall(INTERNAL_REGEX,
raw_relationships_schemas)
new_relationships_schemas.extend(
relationships_schemas_text_to_list_of_dict(schemas_rels)
)
diff --git
a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py
b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py
index 1b67f76..42d36ac 100644
--- a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py
+++ b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/parse_text_to_data.py
@@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+
import re
from typing import List
@@ -89,8 +91,7 @@ def split_string_to_fit_token_space(
current_chunk = ""
for chunk in chunked_data:
if (
- llm.num_tokens_from_string(current_chunk)
- + llm.num_tokens_from_string(chunk)
+ llm.num_tokens_from_string(current_chunk) +
llm.num_tokens_from_string(chunk)
< allowed_tokens
):
current_chunk += chunk
@@ -123,10 +124,8 @@ def get_nodes_and_relationships_from_result(result):
nodes.extend(re.findall(internal_regex, raw_nodes))
relationships.extend(re.findall(internal_regex, raw_relationships))
nodes_schemas.extend(re.findall(internal_regex, raw_nodes_schemas))
- relationships_schemas.extend(
- re.findall(internal_regex, raw_relationships_schemas)
- )
- result = dict()
+ relationships_schemas.extend(re.findall(internal_regex,
raw_relationships_schemas))
+ result = {}
result["nodes"] = []
result["relationships"] = []
result["nodes_schemas"] = []
@@ -159,9 +158,7 @@ class ParseTextToData:
def run(self, data: dict) -> dict[str, list[any]]:
system_message = generate_system_message()
prompt_string = generate_prompt("")
- token_usage_per_prompt = self.llm.num_tokens_from_string(
- system_message + prompt_string
- )
+ token_usage_per_prompt =
self.llm.num_tokens_from_string(system_message + prompt_string)
chunked_data = split_string_to_fit_token_space(
llm=self.llm, string=self.text,
token_use_per_string=token_usage_per_prompt
)
@@ -178,9 +175,7 @@ class ParseTextToData:
class ParseTextToDataWithSchemas:
llm: BaseLLM
- def __init__(
- self, llm: BaseLLM, text: str, nodes_schema, relationships_schemas
- ) -> None:
+ def __init__(self, llm: BaseLLM, text: str, nodes_schema,
relationships_schemas) -> None:
self.llm = llm
self.text = text
self.data = {}
@@ -204,9 +199,7 @@ class ParseTextToDataWithSchemas:
def run(self) -> dict[str, list[any]]:
system_message = generate_system_message_with_schemas()
prompt_string = generate_prompt_with_schemas("", "", "")
- token_usage_per_prompt = self.llm.num_tokens_from_string(
- system_message + prompt_string
- )
+ token_usage_per_prompt =
self.llm.num_tokens_from_string(system_message + prompt_string)
chunked_data = split_string_to_fit_token_space(
llm=self.llm, string=self.text,
token_use_per_string=token_usage_per_prompt
)
diff --git
a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/unstructured_data_utils.py
b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/unstructured_data_utils.py
index 9451b65..f02b9cf 100644
---
a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/unstructured_data_utils.py
+++
b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/unstructured_data_utils.py
@@ -14,13 +14,20 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+
import json
import re
-regex =
r"Nodes:\s+(.*?)\s?\s?Relationships:\s?\s?NodesSchemas:\s+(.*?)\s?\s?RelationshipsSchemas:\s?\s?(.*)"
-internalRegex = r"\[(.*?)\]"
-jsonRegex = r"\{.*\}"
-jsonRegex_relationships = r"\{.*?\}"
+REGEX = (
+ r"Nodes:\s+(.*?)\s?\s?"
+ r"Relationships:\s?\s?"
+ r"NodesSchemas:\s+(.*?)\s?\s?"
+ r"RelationshipsSchemas:\s?\s?(.*)"
+)
+INTERNAL_REGEX = r"\[(.*?)\]"
+JSON_REGEX = r"\{.*\}"
+JSON_REGEX_RELATIONSHIPS = r"\{.*?\}"
def nodes_text_to_list_of_dict(nodes):
@@ -32,7 +39,7 @@ def nodes_text_to_list_of_dict(nodes):
name = node_list[0].strip().replace('"', "")
label = node_list[1].strip().replace('"', "")
- properties = re.search(jsonRegex, node)
+ properties = re.search(JSON_REGEX, node)
if properties is None:
properties = "{}"
else:
@@ -56,7 +63,7 @@ def relationships_text_to_list_of_dict(relationships):
end = {}
properties = {}
relationship_type = relationship_list[1].strip().replace('"', "")
- matches = re.findall(jsonRegex_relationships, relationship)
+ matches = re.findall(JSON_REGEX_RELATIONSHIPS, relationship)
i = 1
for match in matches:
if i == 1:
@@ -89,7 +96,7 @@ def nodes_schemas_text_to_list_of_dict(nodes_schemas):
label = nodes_schema_list[0].strip().replace('"', "")
primary_key = nodes_schema_list[1].strip().replace('"', "")
- properties = re.search(jsonRegex, nodes_schema)
+ properties = re.search(JSON_REGEX, nodes_schema)
if properties is None:
properties = "{}"
else:
@@ -99,9 +106,7 @@ def nodes_schemas_text_to_list_of_dict(nodes_schemas):
properties = json.loads(properties)
except json.decoder.JSONDecodeError:
properties = {}
- result.append(
- {"label": label, "primary_key": primary_key, "properties":
properties}
- )
+ result.append({"label": label, "primary_key": primary_key,
"properties": properties})
return result
@@ -113,11 +118,9 @@ def
relationships_schemas_text_to_list_of_dict(relationships_schemas):
continue
start = relationships_schema_list[0].strip().replace('"', "")
end = relationships_schema_list[2].strip().replace('"', "")
- relationships_schema_type = (
- relationships_schema_list[1].strip().replace('"', "")
- )
+ relationships_schema_type =
relationships_schema_list[1].strip().replace('"', "")
- properties = re.search(jsonRegex, relationships_schema)
+ properties = re.search(JSON_REGEX, relationships_schema)
if properties is None:
properties = "{}"
else:
diff --git a/hugegraph-python-client/example/client_test.py
b/hugegraph-python-client/example/client_test.py
deleted file mode 100644
index 323780b..0000000
--- a/hugegraph-python-client/example/client_test.py
+++ /dev/null
@@ -1,23 +0,0 @@
-import unittest
-from typing import Any
-from unittest.mock import MagicMock, patch
-
-from example.hugegraph_test import HugeGraph
-
-
-class HugeGraphTest(unittest.TestCase):
- def setUp(self) -> None:
- self.username = "test_user"
- self.password = "test_password"
- self.address = "test_address"
- self.graph = "test_hugegraph"
- self.port = 1234
- self.session_pool_size = 10
-
- @patch("src.client.PyHugeGraph")
- def test_init(self, mock_graph: Any) -> None:
- mock_graph.return_value = MagicMock()
- client = HugeGraph(self.username, self.password, self.address,
self.port, self.graph)
-
- result = client.exec("g.V().limit(10)")
- self.assertIsInstance(result, MagicMock)
diff --git a/hugegraph-python-client/example/hugegraph_test.py
b/hugegraph-python-client/example/hugegraph_test.py
index 23b8de6..8b47f51 100644
--- a/hugegraph-python-client/example/hugegraph_test.py
+++ b/hugegraph-python-client/example/hugegraph_test.py
@@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
+
class HugeGraph:
"""HugeGraph wrapper for graph operations"""
@@ -24,7 +25,7 @@ class HugeGraph:
password: str = "default",
address: str = "127.0.0.1",
port: int = 8081,
- graph: str = "hugegraph"
+ graph: str = "hugegraph",
) -> None:
"""Create a new HugeGraph wrapper instance."""
try:
@@ -33,7 +34,7 @@ class HugeGraph:
raise ValueError(
"Please install HugeGraph Python client first: "
"`pip3 install hugegraph-python-client`"
- )
+ ) from ImportError
self.username = username
self.password = password
diff --git a/hugegraph-python-client/example/test.py
b/hugegraph-python-client/example/test.py
index adf3c2e..5162444 100644
--- a/hugegraph-python-client/example/test.py
+++ b/hugegraph-python-client/example/test.py
@@ -17,7 +17,7 @@
from pyhugegraph.client import PyHugeClient
-if __name__ == '__main__':
+if __name__ == "__main__":
client = PyHugeClient("127.0.0.1", "8080", user="admin", pwd="admin",
graph="test")
"""schema"""
@@ -25,9 +25,11 @@ if __name__ == '__main__':
schema.propertyKey("name").asText().ifNotExist().create()
schema.propertyKey("birthDate").asText().ifNotExist().create()
schema.vertexLabel("Person").properties("name",
"birthDate").usePrimaryKeyId().primaryKeys(
- "name").ifNotExist().create()
+ "name"
+ ).ifNotExist().create()
schema.vertexLabel("Movie").properties("name").usePrimaryKeyId().primaryKeys(
- "name").ifNotExist().create()
+ "name"
+ ).ifNotExist().create()
schema.edgeLabel("ActedIn").sourceLabel("Person").targetLabel("Movie").ifNotExist().create()
print(schema.getVertexLabels())
diff --git a/hugegraph-python-client/src/pyhugegraph/api/common.py
b/hugegraph-python-client/src/pyhugegraph/api/common.py
index 8daefec..a1dd7d8 100644
--- a/hugegraph-python-client/src/pyhugegraph/api/common.py
+++ b/hugegraph-python-client/src/pyhugegraph/api/common.py
@@ -27,8 +27,7 @@ class ParameterHolder:
def get_value(self, key):
if key not in self._dic:
return None
- else:
- return self._dic[key]
+ return self._dic[key]
def get_dic(self):
return self._dic
@@ -44,18 +43,15 @@ class HugeParamsBase:
self._port = graph_instance.port
self._user = graph_instance.user_name
self._pwd = graph_instance.passwd
- self._host = "http://{}:{}".format(graph_instance.ip,
graph_instance.port)
+ self._host = f"http://{graph_instance.ip}:{graph_instance.port}"
self._auth = (graph_instance.user_name, graph_instance.passwd)
self._graph_name = graph_instance.graph_name
self._parameter_holder = None
- self._headers = {
- 'Content-Type': Constants.HEADER_CONTENT_TYPE
- }
+ self._headers = {"Content-Type": Constants.HEADER_CONTENT_TYPE}
self._timeout = graph_instance.timeout
def add_parameter(self, key, value):
self._parameter_holder.set(key, value)
- return
def get_parameter_holder(self):
return self._parameter_holder
diff --git a/hugegraph-python-client/src/pyhugegraph/api/graph.py
b/hugegraph-python-client/src/pyhugegraph/api/graph.py
index 0d0c278..393f0e4 100644
--- a/hugegraph-python-client/src/pyhugegraph/api/graph.py
+++ b/hugegraph-python-client/src/pyhugegraph/api/graph.py
@@ -39,27 +39,37 @@ class GraphManager(HugeParamsBase):
self.session.close()
def addVertex(self, label, properties, id=None):
- data = dict()
+ data = {}
if id is not None:
- data['id'] = id
- data['label'] = label
+ data["id"] = id
+ data["label"] = label
data["properties"] = properties
- url = f'{self._host}/graphs/{self._graph_name}/graph/vertices'
- response = self.session.post(url, data=json.dumps(data),
auth=self._auth,
- headers=self._headers,
timeout=self._timeout)
- if check_if_success(response, CreateError("create vertex failed:
{}".format(response.content))):
+ url = f"{self._host}/graphs/{self._graph_name}/graph/vertices"
+ response = self.session.post(
+ url,
+ data=json.dumps(data),
+ auth=self._auth,
+ headers=self._headers,
+ timeout=self._timeout,
+ )
+ if check_if_success(response, CreateError(f"create vertex failed:
{response.content}")):
res = VertexData(json.loads(response.content))
return res
def addVertices(self, input_data):
- url = f'{self._host}/graphs/{self._graph_name}/graph/vertices/batch'
+ url = f"{self._host}/graphs/{self._graph_name}/graph/vertices/batch"
data = []
for item in input_data:
- data.append({'label': item[0], 'properties': item[1]})
- response = self.session.post(url, data=json.dumps(data),
auth=self._auth,
- headers=self._headers,
timeout=self._timeout)
- if check_if_success(response, CreateError("create vertexes failed:
{}".format(response.content))):
+ data.append({"label": item[0], "properties": item[1]})
+ response = self.session.post(
+ url,
+ data=json.dumps(data),
+ auth=self._auth,
+ headers=self._headers,
+ timeout=self._timeout,
+ )
+ if check_if_success(response, CreateError(f"create vertexes failed:
{response.content}")):
res = []
for item in json.loads(response.content):
res.append(VertexData({"id": item}))
@@ -68,58 +78,70 @@ class GraphManager(HugeParamsBase):
def appendVertex(self, vertex_id, properties):
url =
f'{self._host}/graphs/{self._graph_name}/graph/vertices/"{vertex_id}"?action=append'
- data = {
- "properties": properties
- }
- response = self.session.put(url, data=json.dumps(data),
auth=self._auth,
- headers=self._headers,
timeout=self._timeout)
- if check_if_success(response, UpdateError("append vertex failed:
{}".format(response.content))):
+ data = {"properties": properties}
+ response = self.session.put(
+ url,
+ data=json.dumps(data),
+ auth=self._auth,
+ headers=self._headers,
+ timeout=self._timeout,
+ )
+ if check_if_success(response, UpdateError(f"append vertex failed:
{response.content}")):
res = VertexData(json.loads(response.content))
return res
def eliminateVertex(self, vertex_id, properties):
- url =
f'{self._host}/graphs/{self._graph_name}/graph/vertices/"{vertex_id}"?action=eliminate'
-
- data = {
- "properties": properties
- }
- response = self.session.put(url, data=json.dumps(data),
auth=self._auth, headers=self._headers,
- timeout=self._timeout)
- if check_if_success(response, UpdateError("eliminate vertex failed:
{}".format(response.content))):
+ url = (
+
f'{self._host}/graphs/{self._graph_name}/graph/vertices/"{vertex_id}"?action=eliminate'
+ )
+
+ data = {"properties": properties}
+ response = self.session.put(
+ url,
+ data=json.dumps(data),
+ auth=self._auth,
+ headers=self._headers,
+ timeout=self._timeout,
+ )
+ if check_if_success(response, UpdateError(f"eliminate vertex failed:
{response.content}")):
res = VertexData(json.loads(response.content))
return res
def getVertexById(self, vertex_id):
url =
f'{self._host}/graphs/{self._graph_name}/graph/vertices/"{vertex_id}"'
- response = self.session.get(url, auth=self._auth,
headers=self._headers, timeout=self._timeout)
- if check_if_success(response, NotFoundError("Vertex not found:
{}".format(response.content))):
+ response = self.session.get(
+ url, auth=self._auth, headers=self._headers, timeout=self._timeout
+ )
+ if check_if_success(response, NotFoundError(f"Vertex not found:
{response.content}")):
res = VertexData(json.loads(response.content))
return res
def getVertexByPage(self, label, limit, page, properties=None):
- url = f'{self._host}/graphs/{self._graph_name}/graph/vertices?'
+ url = f"{self._host}/graphs/{self._graph_name}/graph/vertices?"
para = ""
para = para + "&label=" + label
if properties:
para = para + "&properties=" + json.dumps(properties)
if page:
- para += '&page={}'.format(page)
+ para += f"&page={page}"
else:
- para += '&page'
+ para += "&page"
para = para + "&limit=" + str(limit)
url = url + para[1:]
- response = self.session.get(url, auth=self._auth,
headers=self._headers, timeout=self._timeout)
- if check_if_success(response, NotFoundError("Vertex not found:
{}".format(response.content))):
+ response = self.session.get(
+ url, auth=self._auth, headers=self._headers, timeout=self._timeout
+ )
+ if check_if_success(response, NotFoundError(f"Vertex not found:
{response.content}")):
res = []
for item in json.loads(response.content)["vertices"]:
res.append(VertexData(item))
next_page = json.loads(response.content)["page"]
return res, next_page
- def getVertexByCondition(self, label="", limit=0, page='',
properties=None):
- url = f'{self._host}/graphs/{self._graph_name}/graph/vertices?'
+ def getVertexByCondition(self, label="", limit=0, page="",
properties=None):
+ url = f"{self._host}/graphs/{self._graph_name}/graph/vertices?"
para = ""
if label:
@@ -129,12 +151,14 @@ class GraphManager(HugeParamsBase):
if limit > 0:
para = para + "&limit=" + str(limit)
if page:
- para += '&page={}'.format(page)
+ para += f"&page={page}"
else:
- para += '&page'
+ para += "&page"
url = url + para[1:]
- response = self.session.get(url, auth=self._auth,
headers=self._headers, timeout=self._timeout)
- if check_if_success(response, NotFoundError("Vertex not found:
{}".format(response.content))):
+ response = self.session.get(
+ url, auth=self._auth, headers=self._headers, timeout=self._timeout
+ )
+ if check_if_success(response, NotFoundError(f"Vertex not found:
{response.content}")):
res = []
for item in json.loads(response.content)["vertices"]:
res.append(VertexData(item))
@@ -142,79 +166,104 @@ class GraphManager(HugeParamsBase):
def removeVertexById(self, vertex_id):
url =
f'{self._host}/graphs/{self._graph_name}/graph/vertices/"{vertex_id}"'
- response = self.session.delete(url, auth=self._auth,
headers=self._headers, timeout=self._timeout)
- if check_if_success(response, RemoveError("remove vertex failed:
{}".format(response.content))):
+ response = self.session.delete(
+ url, auth=self._auth, headers=self._headers, timeout=self._timeout
+ )
+ if check_if_success(response, RemoveError(f"remove vertex failed:
{response.content}")):
return response.content
def addEdge(self, edge_label, out_id, in_id, properties):
- url = f'{self._host}/graphs/{self._graph_name}/graph/edges'
-
- data = {
- "label": edge_label,
- "outV": out_id,
- "inV": in_id,
- "properties": properties
- }
- response = self.session.post(url, data=json.dumps(data),
auth=self._auth,
- headers=self._headers,
timeout=self._timeout)
- if check_if_success(response, CreateError("created edge failed:
{}".format(response.content))):
+ url = f"{self._host}/graphs/{self._graph_name}/graph/edges"
+
+ data = {"label": edge_label, "outV": out_id, "inV": in_id,
"properties": properties}
+ response = self.session.post(
+ url,
+ data=json.dumps(data),
+ auth=self._auth,
+ headers=self._headers,
+ timeout=self._timeout,
+ )
+ if check_if_success(response, CreateError(f"created edge failed:
{response.content}")):
res = EdgeData(json.loads(response.content))
return res
def addEdges(self, input_data):
- url = f'{self._host}/graphs/{self._graph_name}/graph/edges/batch'
+ url = f"{self._host}/graphs/{self._graph_name}/graph/edges/batch"
data = []
for item in input_data:
- data.append({'label': item[0], 'outV': item[1], 'inV': item[2],
'outVLabel': item[3],
- 'inVLabel': item[4], 'properties': item[5]})
- response = self.session.post(url, data=json.dumps(data),
auth=self._auth,
- headers=self._headers,
timeout=self._timeout)
- if check_if_success(response, CreateError("created edges failed:
{}".format(response.content))):
+ data.append(
+ {
+ "label": item[0],
+ "outV": item[1],
+ "inV": item[2],
+ "outVLabel": item[3],
+ "inVLabel": item[4],
+ "properties": item[5],
+ }
+ )
+ response = self.session.post(
+ url,
+ data=json.dumps(data),
+ auth=self._auth,
+ headers=self._headers,
+ timeout=self._timeout,
+ )
+ if check_if_success(response, CreateError(f"created edges failed:
{response.content}")):
res = []
for item in json.loads(response.content):
res.append(EdgeData({"id": item}))
return res
def appendEdge(self, edge_id, properties):
- url =
f'{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}?action=append'
-
- data = {
- "properties": properties
- }
- response = self.session.put(url, data=json.dumps(data),
auth=self._auth,
- headers=self._headers,
timeout=self._timeout)
- if check_if_success(response, UpdateError("append edge failed:
{}".format(response.content))):
+ url =
f"{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}?action=append"
+
+ data = {"properties": properties}
+ response = self.session.put(
+ url,
+ data=json.dumps(data),
+ auth=self._auth,
+ headers=self._headers,
+ timeout=self._timeout,
+ )
+ if check_if_success(response, UpdateError(f"append edge failed:
{response.content}")):
res = EdgeData(json.loads(response.content))
return res
def eliminateEdge(self, edge_id, properties):
- url =
f'{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}?action=eliminate'
-
- data = {
- "properties": properties
- }
- response = self.session.put(url, data=json.dumps(data),
auth=self._auth,
- headers=self._headers,
timeout=self._timeout)
- if check_if_success(response, UpdateError("eliminate edge failed:
{}".format(response.content))):
+ url =
f"{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}?action=eliminate"
+
+ data = {"properties": properties}
+ response = self.session.put(
+ url,
+ data=json.dumps(data),
+ auth=self._auth,
+ headers=self._headers,
+ timeout=self._timeout,
+ )
+ if check_if_success(response, UpdateError(f"eliminate edge failed:
{response.content}")):
res = EdgeData(json.loads(response.content))
return res
def getEdgeById(self, edge_id):
- url = f'{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}'
+ url = f"{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}"
- response = self.session.get(url, auth=self._auth,
headers=self._headers, timeout=self._timeout)
- if check_if_success(response, NotFoundError("not found edge:
{}".format(response.content))):
+ response = self.session.get(
+ url, auth=self._auth, headers=self._headers, timeout=self._timeout
+ )
+ if check_if_success(response, NotFoundError(f"not found edge:
{response.content}")):
res = EdgeData(json.loads(response.content))
return res
- def getEdgeByPage(self, label=None, vertex_id=None, direction=None,
limit=0, page=None, properties=None):
- url = f'{self._host}/graphs/{self._graph_name}/graph/edges?'
+ def getEdgeByPage(
+ self, label=None, vertex_id=None, direction=None, limit=0, page=None,
properties=None
+ ):
+ url = f"{self._host}/graphs/{self._graph_name}/graph/edges?"
para = ""
if vertex_id:
if direction:
- para = para + "&vertex_id=\"" + vertex_id + "\"&direction=" +
direction
+ para = para + '&vertex_id="' + vertex_id + '"&direction=' +
direction
else:
raise NotFoundError("Direction can not be empty.")
if label:
@@ -222,34 +271,40 @@ class GraphManager(HugeParamsBase):
if properties:
para = para + "&properties=" + json.dumps(properties)
if page:
- para += '&page={}'.format(page)
+ para += f"&page={page}"
else:
- para += '&page'
+ para += "&page"
if limit > 0:
para = para + "&limit=" + str(limit)
url = url + para[1:]
- response = self.session.get(url, auth=self._auth,
headers=self._headers, timeout=self._timeout)
- if check_if_success(response, NotFoundError("not found edges:
{}".format(response.content))):
+ response = self.session.get(
+ url, auth=self._auth, headers=self._headers, timeout=self._timeout
+ )
+ if check_if_success(response, NotFoundError(f"not found edges:
{response.content}")):
res = []
for item in json.loads(response.content)["edges"]:
res.append(EdgeData(item))
return res, json.loads(response.content)["page"]
def removeEdgeById(self, edge_id):
- url = f'{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}'
+ url = f"{self._host}/graphs/{self._graph_name}/graph/edges/{edge_id}"
- response = self.session.delete(url, auth=self._auth,
headers=self._headers, timeout=self._timeout)
- if check_if_success(response, RemoveError("remove edge failed:
{}".format(response.content))):
+ response = self.session.delete(
+ url, auth=self._auth, headers=self._headers, timeout=self._timeout
+ )
+ if check_if_success(response, RemoveError(f"remove edge failed:
{response.content}")):
return response.content
def getVerticesById(self, vertex_ids):
if not vertex_ids:
return []
- url = f'{self._host}/graphs/{self._graph_name}/traversers/vertices?'
+ url = f"{self._host}/graphs/{self._graph_name}/traversers/vertices?"
for vertex_id in vertex_ids:
- url += 'ids="{}"&'.format(vertex_id)
+ url += f'ids="{vertex_id}"&'
url = url.rstrip("&")
- response = self.session.get(url, auth=self._auth,
headers=self._headers, timeout=self._timeout)
+ response = self.session.get(
+ url, auth=self._auth, headers=self._headers, timeout=self._timeout
+ )
if response.status_code == 200 and check_if_authorized(response):
res = []
for item in json.loads(response.content)["vertices"]:
@@ -261,11 +316,13 @@ class GraphManager(HugeParamsBase):
def getEdgesById(self, edge_ids):
if not edge_ids:
return []
- url = f'{self._host}/graphs/{self._graph_name}/traversers/edges?'
+ url = f"{self._host}/graphs/{self._graph_name}/traversers/edges?"
for vertex_id in edge_ids:
- url += 'ids={}&'.format(vertex_id)
+ url += f"ids={vertex_id}&"
url = url.rstrip("&")
- response = self.session.get(url, auth=self._auth,
headers=self._headers, timeout=self._timeout)
+ response = self.session.get(
+ url, auth=self._auth, headers=self._headers, timeout=self._timeout
+ )
if response.status_code == 200 and check_if_authorized(response):
res = []
for item in json.loads(response.content)["edges"]:
diff --git a/hugegraph-python-client/src/pyhugegraph/api/graphs.py
b/hugegraph-python-client/src/pyhugegraph/api/graphs.py
index b44aa6d..9db1b56 100644
--- a/hugegraph-python-client/src/pyhugegraph/api/graphs.py
+++ b/hugegraph-python-client/src/pyhugegraph/api/graphs.py
@@ -11,13 +11,10 @@
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either expresponses or implied. See the License for the
+# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import json
-import re
-import requests
from pyhugegraph.api.common import HugeParamsBase
@@ -41,31 +38,37 @@ class GraphsManager(HugeParamsBase):
self.session.close()
def get_all_graphs(self):
- url = f'{self._host}/graphs'
+ url = f"{self._host}/graphs"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
if check_if_success(response, NotFoundError(response.content)):
return str(response.content)
+ return ""
def get_version(self):
- url = f'{self._host}/versions'
+ url = f"{self._host}/versions"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
if check_if_success(response, NotFoundError(response.content)):
return str(response.content)
+ return ""
def get_graph_info(self):
- url = f'{self._host}/graphs/{self._graph_name}'
+ url = f"{self._host}/graphs/{self._graph_name}"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
if check_if_success(response, NotFoundError(response.content)):
return str(response.content)
+ return ""
def clear_graph_all_data(self):
- url =
f'{self._host}/graphs/{self._graph_name}/clear?confirm_message={Constants.CONFORM_MESSAGE}'
+ url = f"{self._host}/graphs/{self._graph_name}/clear?confirm_message="
\
+ f"{Constants.CONFORM_MESSAGE}"
response = self.session.delete(url, auth=self._auth,
headers=self._headers)
if check_if_success(response, NotFoundError(response.content)):
return str(response.content)
+ return ""
def get_graph_config(self):
url = self._host + "/graphs" + "/" + self._graph_name + "/conf"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
if check_if_success(response, NotFoundError(response.content)):
return str(response.content)
+ return ""
diff --git a/hugegraph-python-client/src/pyhugegraph/api/gremlin.py
b/hugegraph-python-client/src/pyhugegraph/api/gremlin.py
index 562a5bd..8126e5a 100644
--- a/hugegraph-python-client/src/pyhugegraph/api/gremlin.py
+++ b/hugegraph-python-client/src/pyhugegraph/api/gremlin.py
@@ -17,8 +17,6 @@
import json
import re
-import requests
-
from pyhugegraph.api.common import HugeParamsBase
from pyhugegraph.structure.respon_data import ResponseData
from pyhugegraph.utils.exceptions import NotFoundError
@@ -41,8 +39,9 @@ class GremlinManager(HugeParamsBase):
def exec(self, gremlin):
gremlin = re.sub("^g", self._graph_name + ".traversal()", gremlin)
- url = f'{self._host}/gremlin?gremlin={gremlin}'
+ url = f"{self._host}/gremlin?gremlin={gremlin}"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
- error = NotFoundError("Gremlin can't get results:
{}".format(response.content))
+ error = NotFoundError(f"Gremlin can't get results: {response.content}")
if check_if_success(response, error):
return ResponseData(json.loads(response.content)).result
+ return ""
diff --git a/hugegraph-python-client/src/pyhugegraph/api/schema.py
b/hugegraph-python-client/src/pyhugegraph/api/schema.py
index c0f6c83..10da5b3 100644
--- a/hugegraph-python-client/src/pyhugegraph/api/schema.py
+++ b/hugegraph-python-client/src/pyhugegraph/api/schema.py
@@ -80,8 +80,9 @@ class SchemaManager(HugeParamsBase):
"""
create schemas
"""
+
def getSchema(self):
- url = f'{self._host}/graphs/{self._graph_name}/schema'
+ url = f"{self._host}/graphs/{self._graph_name}/schema"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
error = NotFoundError(f"schema not found: {response.content}")
if check_if_success(response, error):
@@ -89,7 +90,7 @@ class SchemaManager(HugeParamsBase):
return schema
def getPropertyKey(self, property_name):
- url =
f'{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}'
+ url =
f"{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
error = NotFoundError(f"PropertyKey not found: {response.content}")
if check_if_success(response, error):
@@ -97,7 +98,7 @@ class SchemaManager(HugeParamsBase):
return property_keys_data
def getPropertyKeys(self):
- url = f'{self._host}/graphs/{self._graph_name}/schema/propertykeys'
+ url = f"{self._host}/graphs/{self._graph_name}/schema/propertykeys"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
res = []
if check_if_success(response):
@@ -106,15 +107,15 @@ class SchemaManager(HugeParamsBase):
return res
def getVertexLabel(self, name):
- url =
f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}'
+ url =
f"{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
- error = NotFoundError("VertexLabel not found:
{}".format(response.content))
+ error = NotFoundError(f"VertexLabel not found: {response.content}")
if check_if_success(response, error):
res = VertexLabelData(json.loads(response.content))
return res
def getVertexLabels(self):
- url = f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels'
+ url = f"{self._host}/graphs/{self._graph_name}/schema/vertexlabels"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
res = []
if check_if_success(response):
@@ -123,15 +124,15 @@ class SchemaManager(HugeParamsBase):
return res
def getEdgeLabel(self, label_name):
- url =
f'{self._host}/graphs/{self._graph_name}/schema/edgelabels/{label_name}'
+ url =
f"{self._host}/graphs/{self._graph_name}/schema/edgelabels/{label_name}"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
- error = NotFoundError("EdgeLabel not found:
{}".format(response.content))
+ error = NotFoundError(f"EdgeLabel not found: {response.content}")
if check_if_success(response, error):
res = EdgeLabelData(json.loads(response.content))
return res
def getEdgeLabels(self):
- url = f'{self._host}/graphs/{self._graph_name}/schema/edgelabels'
+ url = f"{self._host}/graphs/{self._graph_name}/schema/edgelabels"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
res = []
if check_if_success(response):
@@ -140,7 +141,7 @@ class SchemaManager(HugeParamsBase):
return res
def getRelations(self):
- url = f'{self._host}/graphs/{self._graph_name}/schema/edgelabels'
+ url = f"{self._host}/graphs/{self._graph_name}/schema/edgelabels"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
res = []
if check_if_success(response):
@@ -149,18 +150,18 @@ class SchemaManager(HugeParamsBase):
return res
def getIndexLabel(self, name):
- url =
f'{self._host}/graphs/{self._graph_name}/schema/indexlabels/{name}'
+ url =
f"{self._host}/graphs/{self._graph_name}/schema/indexlabels/{name}"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
- error = NotFoundError("EdgeLabel not found:
{}".format(response.content))
+ error = NotFoundError(f"EdgeLabel not found: {response.content}")
if check_if_success(response, error):
res = IndexLabelData(json.loads(response.content))
return res
def getIndexLabels(self):
- url = f'{self._host}/graphs/{self._graph_name}/schema/indexlabels'
+ url = f"{self._host}/graphs/{self._graph_name}/schema/indexlabels"
response = self.session.get(url, auth=self._auth,
headers=self._headers)
res = []
if check_if_success(response):
- for item in json.loads(response.content)['indexlabels']:
+ for item in json.loads(response.content)["indexlabels"]:
res.append(IndexLabelData(item))
- return res
+ return res
diff --git
a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py
b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py
index 502d084..78cbcb5 100644
--- a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py
+++ b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/edge_label.py
@@ -11,7 +11,7 @@
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either expresponses or implied. See the License for the
+# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
@@ -47,7 +47,7 @@ class EdgeLabel(HugeParamsBase):
@decorator_params
def userdata(self, *args):
if not self._parameter_holder.get_value("user_data"):
- self._parameter_holder.set('user_data', dict())
+ self._parameter_holder.set("user_data", {})
user_data = self._parameter_holder.get_value("user_data")
i = 0
while i < len(args):
@@ -93,58 +93,81 @@ class EdgeLabel(HugeParamsBase):
@decorator_create
def create(self):
dic = self._parameter_holder.get_dic()
- data = dict()
- keys = ['name', 'source_label', 'target_label', 'nullable_keys',
'properties',
- 'enable_label_index', 'sort_keys', 'user_data', 'frequency']
+ data = {}
+ keys = [
+ "name",
+ "source_label",
+ "target_label",
+ "nullable_keys",
+ "properties",
+ "enable_label_index",
+ "sort_keys",
+ "user_data",
+ "frequency",
+ ]
for key in keys:
if key in dic:
data[key] = dic[key]
- url = f'{self._host}/graphs/{self._graph_name}/schema/edgelabels'
- response = self.session.post(url, data=json.dumps(data),
auth=self._auth, headers=self._headers)
+ url = f"{self._host}/graphs/{self._graph_name}/schema/edgelabels"
+ response = self.session.post(
+ url, data=json.dumps(data), auth=self._auth, headers=self._headers
+ )
self.clean_parameter_holder()
- error = CreateError('CreateError: "create EdgeLabel failed", Detail:
"{}"'
- .format(str(response.content)))
+ error = CreateError(
+ f'CreateError: "create EdgeLabel failed", Detail:
"{str(response.content)}"'
+ )
if check_if_success(response, error):
- return 'create EdgeLabel success, Detail:
"{}"'.format(str(response.content))
+ return f'create EdgeLabel success, Detail:
"{str(response.content)}"'
@decorator_params
def remove(self):
url =
f'{self._host}/graphs/{self._graph_name}/schema/edgelabels/{self._parameter_holder.get_value("name")}'
response = self.session.delete(url, auth=self._auth,
headers=self._headers)
self.clean_parameter_holder()
- error = RemoveError('RemoveError: "remove EdgeLabel failed", Detail:
"{}"'
- .format(str(response.content)))
+ error = RemoveError(
+ f'RemoveError: "remove EdgeLabel failed", Detail:
"{str(response.content)}"'
+ )
if check_if_success(response, error):
- return 'remove EdgeLabel success, Detail:
"{}"'.format(str(response.content))
+ return f'remove EdgeLabel success, Detail:
"{str(response.content)}"'
@decorator_params
def append(self):
dic = self._parameter_holder.get_dic()
- data = dict()
- keys = ['name', 'nullable_keys', 'properties', 'user_data']
+ data = {}
+ keys = ["name", "nullable_keys", "properties", "user_data"]
for key in keys:
if key in dic:
data[key] = dic[key]
- url =
f'{self._host}/graphs/{self._graph_name}/schema/edgelabels/{data["name"]}?action=append'
- response = self.session.put(url, data=json.dumps(data),
auth=self._auth, headers=self._headers)
+ url = (
+
f'{self._host}/graphs/{self._graph_name}/schema/edgelabels/{data["name"]}?action=append'
+ )
+ response = self.session.put(
+ url, data=json.dumps(data), auth=self._auth, headers=self._headers
+ )
self.clean_parameter_holder()
- error = UpdateError('UpdateError: "append EdgeLabel failed", Detail:
"{}"'.format(str(response.content)))
+ error = UpdateError(
+ f'UpdateError: "append EdgeLabel failed", Detail:
"{str(response.content)}"'
+ )
if check_if_success(response, error):
- return 'append EdgeLabel success, Detail:
"{}"'.format(str(response.content))
+ return f'append EdgeLabel success, Detail:
"{str(response.content)}"'
@decorator_params
def eliminate(self):
name = self._parameter_holder.get_value("name")
- user_data = self._parameter_holder.get_value("user_data") if \
- self._parameter_holder.get_value("user_data") else {}
- url =
f'{self._host}/graphs/{self._graph_name}/schema/edgelabels/{name}?action=eliminate'
- data = {
- "name": name,
- "user_data": user_data
- }
- response = self.session.put(url, data=json.dumps(data),
auth=self._auth, headers=self._headers)
+ user_data = (
+ self._parameter_holder.get_value("user_data")
+ if self._parameter_holder.get_value("user_data")
+ else {}
+ )
+ url =
f"{self._host}/graphs/{self._graph_name}/schema/edgelabels/{name}?action=eliminate"
+ data = {"name": name, "user_data": user_data}
+ response = self.session.put(
+ url, data=json.dumps(data), auth=self._auth, headers=self._headers
+ )
self.clean_parameter_holder()
- error = UpdateError('UpdateError: "eliminate EdgeLabel failed",
Detail: "{}"'.format(str(response.content)))
+ error = UpdateError(
+ f'UpdateError: "eliminate EdgeLabel failed", Detail:
"{str(response.content)}"'
+ )
if check_if_success(response, error):
- return 'eliminate EdgeLabel success, Detail:
"{}"'.format(str(response.content))
+ return f'eliminate EdgeLabel success, Detail:
"{str(response.content)}"'
diff --git
a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/index_label.py
b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/index_label.py
index e29c8c7..9ac3829 100644
--- a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/index_label.py
+++ b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/index_label.py
@@ -77,27 +77,31 @@ class IndexLabel(HugeParamsBase):
@decorator_create
def create(self):
dic = self._parameter_holder.get_dic()
- data = dict()
+ data = {}
data["name"] = dic["name"]
data["base_type"] = dic["base_type"]
data["base_value"] = dic["base_value"]
data["index_type"] = dic["index_type"]
data["fields"] = list(dic["fields"])
- url = f'{self._host}/graphs/{self._graph_name}/schema/indexlabels'
- response = self.session.post(url, data=json.dumps(data),
auth=self._auth, headers=self._headers)
+ url = f"{self._host}/graphs/{self._graph_name}/schema/indexlabels"
+ response = self.session.post(
+ url, data=json.dumps(data), auth=self._auth, headers=self._headers
+ )
self.clean_parameter_holder()
- error = CreateError('CreateError: "create IndexLabel failed", '
- 'Detail "{}"'.format(str(response.content)))
+ error = CreateError(
+ f'CreateError: "create IndexLabel failed", Detail
"{str(response.content)}"'
+ )
if check_if_success(response, error):
- return 'create IndexLabel success, Deatil:
"{}"'.format(str(response.content))
+ return f'create IndexLabel success, Deatil:
"{str(response.content)}"'
@decorator_params
def remove(self):
name = self._parameter_holder.get_value("name")
- url =
f'{self._host}/graphs/{self._graph_name}/schema/indexlabels/{name}'
+ url =
f"{self._host}/graphs/{self._graph_name}/schema/indexlabels/{name}"
response = self.session.delete(url, auth=self._auth,
headers=self._headers)
self.clean_parameter_holder()
- error = RemoveError('RemoveError: "remove IndexLabel failed", '
- 'Detail "{}"'.format(str(response.content)))
+ error = RemoveError(
+ f'RemoveError: "remove IndexLabel failed", Detail
"{str(response.content)}"'
+ )
if check_if_success(response, error):
- return 'remove IndexLabel success, Deatil:
"{}"'.format(str(response.content))
+ return f'remove IndexLabel success, Deatil:
"{str(response.content)}"'
diff --git
a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py
b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py
index 7a7f0e7..d0ce9a1 100644
--- a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py
+++ b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/property_key.py
@@ -11,7 +11,7 @@
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either expresponses or implied. See the License for the
+# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
@@ -89,7 +89,7 @@ class PropertyKey(HugeParamsBase):
def userdata(self, *args):
user_data = self._parameter_holder.get_value("user_data")
if not user_data:
- self._parameter_holder.set("user_data", dict())
+ self._parameter_holder.set("user_data", {})
user_data = self._parameter_holder.get_value("user_data")
i = 0
while i < len(args):
@@ -107,55 +107,59 @@ class PropertyKey(HugeParamsBase):
@decorator_create
def create(self):
dic = self._parameter_holder.get_dic()
- property_keys = {
- "name": dic["name"]
- }
+ property_keys = {"name": dic["name"]}
if "data_type" in dic:
property_keys["data_type"] = dic["data_type"]
if "cardinality" in dic:
property_keys["cardinality"] = dic["cardinality"]
- url = f'{self._host}/graphs/{self._graph_name}/schema/propertykeys'
- response = self.session.post(url, data=json.dumps(property_keys),
auth=self._auth, headers=self._headers)
+ url = f"{self._host}/graphs/{self._graph_name}/schema/propertykeys"
+ response = self.session.post(
+ url, data=json.dumps(property_keys), auth=self._auth,
headers=self._headers
+ )
self.clean_parameter_holder()
- if check_if_success(response, CreateError(
- 'CreateError: "create PropertyKey failed", Detail:
{}'.format(response.content))):
- return 'create PropertyKey success, Detail:
{}'.format(response.content)
+ if check_if_success(
+ response,
+ CreateError(f'CreateError: "create PropertyKey failed", Detail:
{response.content}'),
+ ):
+ return f"create PropertyKey success, Detail: {response.content}"
@decorator_params
def append(self):
property_name = self._parameter_holder.get_value("name")
user_data = self._parameter_holder.get_value("user_data")
if not user_data:
- user_data = dict()
- data = {
- "name": property_name,
- "user_data": user_data
- }
-
- url =
f'{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}/?action=append'
- response = self.session.put(url, data=json.dumps(data),
auth=self._auth, headers=self._headers)
+ user_data = {}
+ data = {"name": property_name, "user_data": user_data}
+
+ url =
f"{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}/?action=append"
+ response = self.session.put(
+ url, data=json.dumps(data), auth=self._auth, headers=self._headers
+ )
self.clean_parameter_holder()
- if check_if_success(response, UpdateError(
- 'UpdateError: "append PropertyKey failed", Detail:
{}'.format(response.content))):
- return 'append PropertyKey success, Detail:
{}'.format(response.content)
+ if check_if_success(
+ response,
+ UpdateError(f'UpdateError: "append PropertyKey failed", Detail:
{response.content}'),
+ ):
+ return f"append PropertyKey success, Detail: {response.content}"
@decorator_params
def eliminate(self):
property_name = self._parameter_holder.get_value("name")
user_data = self._parameter_holder.get_value("user_data")
if not user_data:
- user_data = dict()
- data = {
- "name": property_name,
- "user_data": user_data
- }
-
- url =
f'{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}/?action=eliminate'
- response = self.session.put(url, data=json.dumps(data),
auth=self._auth, headers=self._headers)
+ user_data = {}
+ data = {"name": property_name, "user_data": user_data}
+
+ url =
f"{self._host}/graphs/{self._graph_name}/schema/propertykeys/{property_name}/?action=eliminate"
+ response = self.session.put(
+ url, data=json.dumps(data), auth=self._auth, headers=self._headers
+ )
self.clean_parameter_holder()
- error = UpdateError(f'UpdateError: "eliminate PropertyKey failed",
Detail: {str(response.content)}')
+ error = UpdateError(
+ f'UpdateError: "eliminate PropertyKey failed", Detail:
{str(response.content)}'
+ )
if check_if_success(response, error):
- return 'eliminate PropertyKey success, Detail:
{}'.format(str(response.content))
+ return f"eliminate PropertyKey success, Detail:
{str(response.content)}"
@decorator_params
def remove(self):
@@ -163,6 +167,10 @@ class PropertyKey(HugeParamsBase):
url =
f'{self._host}/graphs/{self._graph_name}/schema/propertykeys/{dic["name"]}'
response = self.session.delete(url)
self.clean_parameter_holder()
- if check_if_success(response, RemoveError(
- 'RemoveError: "delete PropertyKey failed", Detail:
{}'.format(str(response.content)))):
- return 'delete PropertyKey success, Detail: {}'.format(dic["name"])
+ if check_if_success(
+ response,
+ RemoveError(
+ f'RemoveError: "delete PropertyKey failed", Detail:
{str(response.content)}'
+ ),
+ ):
+ return f'delete PropertyKey success, Detail: {dic["name"]}'
diff --git
a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/vertex_label.py
b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/vertex_label.py
index e031fd3..3a45cff 100644
--- a/hugegraph-python-client/src/pyhugegraph/api/schema_manage/vertex_label.py
+++ b/hugegraph-python-client/src/pyhugegraph/api/schema_manage/vertex_label.py
@@ -73,8 +73,8 @@ class VertexLabel(HugeParamsBase):
@decorator_params
def userdata(self, *args):
if "user_data" not in self._parameter_holder.get_keys():
- self._parameter_holder.set('user_data', dict())
- user_data = self._parameter_holder.get_value('user_data')
+ self._parameter_holder.set("user_data", {})
+ user_data = self._parameter_holder.get_value("user_data")
i = 0
while i < len(args):
user_data[args[i]] = args[i + 1]
@@ -92,65 +92,83 @@ class VertexLabel(HugeParamsBase):
@decorator_create
def create(self):
dic = self._parameter_holder.get_dic()
- key_list = ["name", "id_strategy", "primary_keys", "nullable_keys",
"index_labels",
- "properties", "enable_label_index", "user_data"]
+ key_list = [
+ "name",
+ "id_strategy",
+ "primary_keys",
+ "nullable_keys",
+ "index_labels",
+ "properties",
+ "enable_label_index",
+ "user_data",
+ ]
data = {}
for key in key_list:
if key in dic:
data[key] = dic[key]
- url = f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels'
- response = self.session.post(url, data=json.dumps(data),
auth=self._auth, headers=self._headers)
+ url = f"{self._host}/graphs/{self._graph_name}/schema/vertexlabels"
+ response = self.session.post(
+ url, data=json.dumps(data), auth=self._auth, headers=self._headers
+ )
self.clean_parameter_holder()
- error = CreateError('CreateError: "create VertexLabel failed", Detail:
"{}"'
- .format(str(response.content)))
+ error = CreateError(
+ f'CreateError: "create VertexLabel failed", Detail:
"{str(response.content)}"'
+ )
if check_if_success(response, error):
- return 'create VertexLabel success, Detail:
"{}"'.format(str(response.content))
+ return f'create VertexLabel success, Detail:
"{str(response.content)}"'
@decorator_params
def append(self):
dic = self._parameter_holder.get_dic()
- properties = dic['properties'] if "properties" in dic else []
- nullable_keys = dic['nullable_keys'] if "nullable_keys" in dic else []
- user_data = dic['user_data'] if 'user_data' in dic else {}
+ properties = dic["properties"] if "properties" in dic else []
+ nullable_keys = dic["nullable_keys"] if "nullable_keys" in dic else []
+ user_data = dic["user_data"] if "user_data" in dic else {}
url =
f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{dic["name"]}?action=append'
data = {
"name": dic["name"],
"properties": properties,
"nullable_keys": nullable_keys,
- "user_data": user_data
+ "user_data": user_data,
}
- response = self.session.put(url, data=json.dumps(data),
auth=self._auth, headers=self._headers)
+ response = self.session.put(
+ url, data=json.dumps(data), auth=self._auth, headers=self._headers
+ )
self.clean_parameter_holder()
- error = UpdateError('UpdateError: "append VertexLabel failed", Detail:
"{}"'.
- format(str(response.content)))
+ error = UpdateError(
+ f'UpdateError: "append VertexLabel failed", Detail:
"{str(response.content)}"'
+ )
if check_if_success(response, error):
- return 'append VertexLabel success, Detail:
"{}"'.format(str(response.content))
+ return f'append VertexLabel success, Detail:
"{str(response.content)}"'
@decorator_params
def remove(self):
name = self._parameter_holder.get_value("name")
- url =
f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}'
+ url =
f"{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}"
response = self.session.delete(url, auth=self._auth,
headers=self._headers)
self.clean_parameter_holder()
- error = RemoveError('RemoveError: "remove VertexLabel failed", Detail:
"{}"'.
- format(str(response.content)))
+ error = RemoveError(
+ f'RemoveError: "remove VertexLabel failed", Detail:
"{str(response.content)}"'
+ )
if check_if_success(response, error):
- return 'remove VertexLabel success, Detail:
"{}"'.format(str(response.content))
+ return f'remove VertexLabel success, Detail:
"{str(response.content)}"'
@decorator_params
def eliminate(self):
name = self._parameter_holder.get_value("name")
- url =
f'{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}/?action=eliminate'
+ url =
f"{self._host}/graphs/{self._graph_name}/schema/vertexlabels/{name}/?action=eliminate"
dic = self._parameter_holder.get_dic()
- user_data = dic['user_data'] if 'user_data' in dic else {}
+ user_data = dic["user_data"] if "user_data" in dic else {}
data = {
"name": self._parameter_holder.get_value("name"),
"user_data": user_data,
}
- response = self.session.put(url, data=json.dumps(data),
auth=self._auth, headers=self._headers)
- error = UpdateError('UpdateError: "eliminate VertexLabel failed",
Detail: "{}"'.
- format(str(response.content)))
+ response = self.session.put(
+ url, data=json.dumps(data), auth=self._auth, headers=self._headers
+ )
+ error = UpdateError(
+ f'UpdateError: "eliminate VertexLabel failed", Detail:
"{str(response.content)}"'
+ )
if check_if_success(response, error):
- return 'eliminate VertexLabel success, Detail:
"{}"'.format(str(response.content))
+ return f'eliminate VertexLabel success, Detail:
"{str(response.content)}"'
diff --git a/hugegraph-python-client/src/pyhugegraph/structure/edge_data.py
b/hugegraph-python-client/src/pyhugegraph/structure/edge_data.py
index 1269e0a..e0732c9 100644
--- a/hugegraph-python-client/src/pyhugegraph/structure/edge_data.py
+++ b/hugegraph-python-client/src/pyhugegraph/structure/edge_data.py
@@ -60,5 +60,5 @@ class EdgeData:
return self.__properties
def __repr__(self):
- res = "{}--{}-->{}".format(self.__outV, self.__label, self.__inV)
+ res = f"{self.__outV}--{self.__label}-->{self.__inV}"
return res
diff --git
a/hugegraph-python-client/src/pyhugegraph/structure/edge_label_data.py
b/hugegraph-python-client/src/pyhugegraph/structure/edge_label_data.py
index 57cfc58..48eb9e4 100644
--- a/hugegraph-python-client/src/pyhugegraph/structure/edge_label_data.py
+++ b/hugegraph-python-client/src/pyhugegraph/structure/edge_label_data.py
@@ -67,12 +67,9 @@ class EdgeLabelData:
return self.__user_data
def relations(self):
- res = "{}--{}-->{}".format(
- self.__source_label, self.__name, self.__target_label)
+ res = f"{self.__source_label}--{self.__name}-->{self.__target_label}"
return res
def __repr__(self):
- res = "name: {}, properties: {}".format(
- self.__name
- , self.__properties)
+ res = f"name: {self.__name}, properties: {self.__properties}"
return res
diff --git
a/hugegraph-python-client/src/pyhugegraph/structure/graph_instance.py
b/hugegraph-python-client/src/pyhugegraph/structure/graph_instance.py
index 34bed43..5defa08 100644
--- a/hugegraph-python-client/src/pyhugegraph/structure/graph_instance.py
+++ b/hugegraph-python-client/src/pyhugegraph/structure/graph_instance.py
@@ -50,5 +50,8 @@ class GraphInstance:
return self.__timeout
def __repr__(self):
- res = f"ip:{self.ip}, port:{self.port}, graph_name:{self.graph_name},
user_name:{self.user_name}, passwd:{self.passwd}, timeout:{self.timeout}"
+ res = (
+ f"ip:{self.ip}, port:{self.port}, graph_name:{self.graph_name},"
+ f" user_name:{self.user_name}, passwd:{self.passwd},
timeout:{self.timeout}"
+ )
return res
diff --git
a/hugegraph-python-client/src/pyhugegraph/structure/index_label_data.py
b/hugegraph-python-client/src/pyhugegraph/structure/index_label_data.py
index 4f60233..65aedfc 100644
--- a/hugegraph-python-client/src/pyhugegraph/structure/index_label_data.py
+++ b/hugegraph-python-client/src/pyhugegraph/structure/index_label_data.py
@@ -50,7 +50,8 @@ class IndexLabelData:
return self.__index_type
def __repr__(self):
- res = "index_name: {}, base_value: {}, base_type: {}, fields: [],
index_type: {}"\
- .format(self.__name, self.__base_value, self.__base_type,
self.__fields,
- self.__index_type)
+ res = (
+ f"index_name: {self.__name}, base_value: {self.__base_value},
base_type:"
+ f" {self.__base_type}, fields: {self.__fields}, index_type:
{self.__index_type}"
+ )
return res
diff --git
a/hugegraph-python-client/src/pyhugegraph/structure/property_key_data.py
b/hugegraph-python-client/src/pyhugegraph/structure/property_key_data.py
index 665d632..9b7b50c 100644
--- a/hugegraph-python-client/src/pyhugegraph/structure/property_key_data.py
+++ b/hugegraph-python-client/src/pyhugegraph/structure/property_key_data.py
@@ -45,7 +45,7 @@ class PropertyKeyData:
return self.__user_data
def __repr__(self):
- res = "name: {}, cardinality: {}, data_type: {}".format(
- self.__name, self.__cardinality, self.__data_type
+ res = (
+ f"name: {self.__name}, cardinality: {self.__cardinality},
data_type: {self.__data_type}"
)
return res
diff --git a/hugegraph-python-client/src/pyhugegraph/structure/respon_data.py
b/hugegraph-python-client/src/pyhugegraph/structure/respon_data.py
index cbbbc81..0f4f1b1 100644
--- a/hugegraph-python-client/src/pyhugegraph/structure/respon_data.py
+++ b/hugegraph-python-client/src/pyhugegraph/structure/respon_data.py
@@ -35,5 +35,5 @@ class ResponseData:
return self.__result
def __repr__(self):
- res = "id: {}, status: {}, result: {}".format(self.__id,
self.__status, self.__result)
+ res = f"id: {self.__id}, status: {self.__status}, result:
{self.__result}"
return res
diff --git a/hugegraph-python-client/src/pyhugegraph/structure/vertex_data.py
b/hugegraph-python-client/src/pyhugegraph/structure/vertex_data.py
index eb358bc..bccee37 100644
--- a/hugegraph-python-client/src/pyhugegraph/structure/vertex_data.py
+++ b/hugegraph-python-client/src/pyhugegraph/structure/vertex_data.py
@@ -40,5 +40,5 @@ class VertexData:
return self.__properties
def __repr__(self):
- res = "id: {}, label: {}, type: {}".format(self.__id, self.__label,
self.__type)
+ res = f"id: {self.__id}, label: {self.__label}, type: {self.__type}"
return res
diff --git
a/hugegraph-python-client/src/pyhugegraph/structure/vertex_label_data.py
b/hugegraph-python-client/src/pyhugegraph/structure/vertex_label_data.py
index fe2a8b5..2a8e443 100644
--- a/hugegraph-python-client/src/pyhugegraph/structure/vertex_label_data.py
+++ b/hugegraph-python-client/src/pyhugegraph/structure/vertex_label_data.py
@@ -57,6 +57,8 @@ class VertexLabelData:
return self.__user_data
def __repr__(self):
- res = "name: {}, primary_keys: {}, properties: {}".format(
- self.__name, self.__primary_keys, self.__properties)
+ res = (
+ f"name: {self.__name}, primary_keys: {self.__primary_keys}, "
+ f"properties: {self.__properties}"
+ )
return res
diff --git a/hugegraph-python-client/src/pyhugegraph/utils/exceptions.py
b/hugegraph-python-client/src/pyhugegraph/utils/exceptions.py
index 7cfb4aa..78fee8c 100644
--- a/hugegraph-python-client/src/pyhugegraph/utils/exceptions.py
+++ b/hugegraph-python-client/src/pyhugegraph/utils/exceptions.py
@@ -18,45 +18,47 @@
class NotAuthorizedError(Exception):
"""
- Not Authorized
+ Not Authorized
"""
+
class InvalidParameter(Exception):
"""
- Parameter setting error
+ Parameter setting error
"""
+
class NotFoundError(Exception):
"""
- no content found
+ no content found
"""
class CreateError(Exception):
"""
- Failed to create vertex or edge
+ Failed to create vertex or edge
"""
class RemoveError(Exception):
"""
- Failed to delete vertex or edge
+ Failed to delete vertex or edge
"""
class UpdateError(Exception):
"""
- Failed to modify node
+ Failed to modify node
"""
class DataFormatError(Exception):
"""
- Input data format error
+ Input data format error
"""
class ServiceUnavailableException(Exception):
"""
- The server is too busy to be available
+ The server is too busy to be available
"""
diff --git a/hugegraph-python-client/src/pyhugegraph/utils/huge_decorator.py
b/hugegraph-python-client/src/pyhugegraph/utils/huge_decorator.py
index 3087778..47906ad 100644
--- a/hugegraph-python-client/src/pyhugegraph/utils/huge_decorator.py
+++ b/hugegraph-python-client/src/pyhugegraph/utils/huge_decorator.py
@@ -24,16 +24,16 @@ from pyhugegraph.utils.exceptions import NotAuthorizedError
def decorator_params(func, *args, **kwargs):
parameter_holder = args[0].get_parameter_holder()
if parameter_holder is None or "name" not in parameter_holder.get_keys():
- print('Parameters required, please set necessary parameters.')
- raise
+ print("Parameters required, please set necessary parameters.")
+ raise Exception("Parameters required, please set necessary
parameters.")
return func(*args, **kwargs)
@decorator
def decorator_create(func, *args, **kwargs):
parameter_holder = args[0].get_parameter_holder()
- if parameter_holder.get_value('not_exist') is False:
- return 'Create failed, "{}" already
exists.'.format(parameter_holder.get_value('name'))
+ if parameter_holder.get_value("not_exist") is False:
+ return f'Create failed, "{parameter_holder.get_value("name")}" already
exists.'
return func(*args, **kwargs)
@@ -41,5 +41,5 @@ def decorator_create(func, *args, **kwargs):
def decorator_auth(func, *args, **kwargs):
response = args[0]
if response.status_code == 401:
- raise NotAuthorizedError("NotAuthorized: {}".format(response.content))
+ raise NotAuthorizedError(f"NotAuthorized: {response.content}")
return func(*args, **kwargs)
diff --git a/hugegraph-python-client/src/pyhugegraph/utils/huge_requests.py
b/hugegraph-python-client/src/pyhugegraph/utils/huge_requests.py
index 744e8b5..57ac233 100644
--- a/hugegraph-python-client/src/pyhugegraph/utils/huge_requests.py
+++ b/hugegraph-python-client/src/pyhugegraph/utils/huge_requests.py
@@ -26,7 +26,7 @@ class HugeSession:
session = requests.Session()
retry = Retry(connect=5, backoff_factor=1)
adapter = HTTPAdapter(max_retries=retry)
- session.mount('http://', adapter)
- session.mount('https://', adapter)
+ session.mount("http://", adapter)
+ session.mount("https://", adapter)
session.keep_alive = False
return session
diff --git a/hugegraph-python-client/src/pyhugegraph/utils/util.py
b/hugegraph-python-client/src/pyhugegraph/utils/util.py
index c5368b0..56d6533 100644
--- a/hugegraph-python-client/src/pyhugegraph/utils/util.py
+++ b/hugegraph-python-client/src/pyhugegraph/utils/util.py
@@ -17,21 +17,26 @@
import json
-from pyhugegraph.utils.exceptions import ServiceUnavailableException,
NotAuthorizedError, NotFoundError
+from pyhugegraph.utils.exceptions import (
+ ServiceUnavailableException,
+ NotAuthorizedError,
+ NotFoundError,
+)
def create_exception(response_content):
data = json.loads(response_content)
if "ServiceUnavailableException" in data["exception"]:
- raise ServiceUnavailableException('ServiceUnavailableException,
"message": "{}", "cause": "{}"'.
- format(data["message"],
data["cause"]))
- else:
- raise Exception(response_content)
+ raise ServiceUnavailableException(
+ f'ServiceUnavailableException, "message": "{data["message"]}",'
+ f' "cause": "{data["cause"]}"'
+ )
+ raise Exception(response_content)
def check_if_authorized(response):
if response.status_code == 401:
- raise NotAuthorizedError("Please check your username and password.
{}".format(response.content))
+ raise NotAuthorizedError(f"Please check your username and password.
{response.content}")
return True
diff --git a/pylint.conf b/pylint.conf
new file mode 100644
index 0000000..a3638df
--- /dev/null
+++ b/pylint.conf
@@ -0,0 +1,647 @@
+[MAIN]
+
+# Analyse import fallback blocks. This can be used to support both Python 2 and
+# 3 compatible code, which means that the block might have code that exists
+# only in one or another interpreter, leading to false positives when analysed.
+analyse-fallback-blocks=no
+
+# Clear in-memory caches upon conclusion of linting. Useful if running pylint
+# in a server-like mode.
+clear-cache-post-run=no
+
+# Load and enable all available extensions. Use --list-extensions to see a list
+# all available extensions.
+#enable-all-extensions=
+
+# In error mode, messages with a category besides ERROR or FATAL are
+# suppressed, and no reports are done by default. Error mode is compatible with
+# disabling specific errors.
+#errors-only=
+
+# Always return a 0 (non-error) status code, even if lint errors are found.
+# This is primarily useful in continuous integration scripts.
+#exit-zero=
+
+# A comma-separated list of package or module names from where C extensions may
+# be loaded. Extensions are loading into the active Python interpreter and may
+# run arbitrary code.
+extension-pkg-allow-list=
+
+# A comma-separated list of package or module names from where C extensions may
+# be loaded. Extensions are loading into the active Python interpreter and may
+# run arbitrary code. (This is an alternative name to extension-pkg-allow-list
+# for backward compatibility.)
+extension-pkg-whitelist=
+
+# Return non-zero exit code if any of these messages/categories are detected,
+# even if score is above --fail-under value. Syntax same as enable. Messages
+# specified are enabled, while categories only check already-enabled messages.
+fail-on=
+
+# Specify a score threshold under which the program will exit with error.
+fail-under=10
+
+# Interpret the stdin as a python script, whose filename needs to be passed as
+# the module_or_package argument.
+#from-stdin=
+
+# Files or directories to be skipped. They should be base names, not paths.
+ignore=CVS
+
+# Add files or directories matching the regular expressions patterns to the
+# ignore-list. The regex matches against paths and can be in Posix or Windows
+# format. Because '\\' represents the directory delimiter on Windows systems,
+# it can't be used as an escape character.
+ignore-paths=./hugegraph-python-client/src/pyhugegraph/structure,./hugegraph-python-client/src/pyhugegraph/api/schema_manage,./hugegraph-python-client/src/pyhugegraph/api/graph.py,./hugegraph-python-client/src/pyhugegraph/api/schema.py
+
+# Files or directories matching the regular expression patterns are skipped.
+# The regex matches against base names, not paths. The default value ignores
+# Emacs file locks
+ignore-patterns=^\.#
+
+# List of module names for which member attributes should not be checked
+# (useful for modules/projects where namespaces are manipulated during runtime
+# and thus existing member attributes cannot be deduced by static analysis). It
+# supports qualified module names, as well as Unix pattern matching.
+ignored-modules=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
+# number of processors available to use, and will cap the count on Windows to
+# avoid hangs.
+jobs=1
+
+# Control the amount of potential inferred values when inferring a single
+# object. This can help the performance when dealing with large functions or
+# complex, nested conditions.
+limit-inference-results=100
+
+# List of plugins (as comma separated values of python module names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# Minimum Python version to use for version dependent checks. Will default to
+# the version used to run pylint.
+py-version=3.11
+
+# Discover python modules and packages in the file system subtree.
+recursive=no
+
+# Add paths to the list of the source roots. Supports globbing patterns. The
+# source root is an absolute path or a path relative to the current working
+# directory used to determine a package namespace for modules located under the
+# source root.
+source-roots=
+
+# When enabled, pylint would attempt to guess common misconfiguration and emit
+# user-friendly hints instead of false-positive error messages.
+suggestion-mode=yes
+
+# Allow loading of arbitrary C extensions. Extensions are imported into the
+# active Python interpreter and may run arbitrary code.
+unsafe-load-any-extension=no
+
+# In verbose mode, extra non-checker-related info will be displayed.
+#verbose=
+
+
+[BASIC]
+
+# Naming style matching correct argument names.
+argument-naming-style=snake_case
+
+# Regular expression matching correct argument names. Overrides argument-
+# naming-style. If left empty, argument names will be checked with the set
+# naming style.
+#argument-rgx=
+
+# Naming style matching correct attribute names.
+attr-naming-style=snake_case
+
+# Regular expression matching correct attribute names. Overrides attr-naming-
+# style. If left empty, attribute names will be checked with the set naming
+# style.
+#attr-rgx=
+
+# Bad variable names which should always be refused, separated by a comma.
+bad-names=foo,
+ bar,
+ baz,
+ toto,
+ tutu,
+ tata
+
+# Bad variable names regexes, separated by a comma. If names match any regex,
+# they will always be refused
+bad-names-rgxs=
+
+# Naming style matching correct class attribute names.
+class-attribute-naming-style=any
+
+# Regular expression matching correct class attribute names. Overrides class-
+# attribute-naming-style. If left empty, class attribute names will be checked
+# with the set naming style.
+#class-attribute-rgx=
+
+# Naming style matching correct class constant names.
+class-const-naming-style=UPPER_CASE
+
+# Regular expression matching correct class constant names. Overrides class-
+# const-naming-style. If left empty, class constant names will be checked with
+# the set naming style.
+#class-const-rgx=
+
+# Naming style matching correct class names.
+class-naming-style=PascalCase
+
+# Regular expression matching correct class names. Overrides class-naming-
+# style. If left empty, class names will be checked with the set naming style.
+#class-rgx=
+
+# Naming style matching correct constant names.
+const-naming-style=UPPER_CASE
+
+# Regular expression matching correct constant names. Overrides const-naming-
+# style. If left empty, constant names will be checked with the set naming
+# style.
+#const-rgx=
+
+# Minimum line length for functions/classes that require docstrings, shorter
+# ones are exempt.
+docstring-min-length=-1
+
+# Naming style matching correct function names.
+function-naming-style=snake_case
+
+# Regular expression matching correct function names. Overrides function-
+# naming-style. If left empty, function names will be checked with the set
+# naming style.
+#function-rgx=
+
+# Good variable names which should always be accepted, separated by a comma.
+good-names=i,
+ j,
+ k,
+ ex,
+ Run,
+ _
+
+# Good variable names regexes, separated by a comma. If names match any regex,
+# they will always be accepted
+good-names-rgxs=
+
+# Include a hint for the correct naming format with invalid-name.
+include-naming-hint=no
+
+# Naming style matching correct inline iteration names.
+inlinevar-naming-style=any
+
+# Regular expression matching correct inline iteration names. Overrides
+# inlinevar-naming-style. If left empty, inline iteration names will be checked
+# with the set naming style.
+#inlinevar-rgx=
+
+# Naming style matching correct method names.
+method-naming-style=snake_case
+
+# Regular expression matching correct method names. Overrides method-naming-
+# style. If left empty, method names will be checked with the set naming style.
+#method-rgx=
+
+# Naming style matching correct module names.
+module-naming-style=snake_case
+
+# Regular expression matching correct module names. Overrides module-naming-
+# style. If left empty, module names will be checked with the set naming style.
+#module-rgx=
+
+# Colon-delimited sets of names that determine each other's naming style when
+# the name regexes allow several styles.
+name-group=
+
+# Regular expression which should only match function or class names that do
+# not require a docstring.
+no-docstring-rgx=^_
+
+# List of decorators that produce properties, such as abc.abstractproperty. Add
+# to this list to register other decorators that produce valid properties.
+# These decorators are taken in consideration only for invalid-name.
+property-classes=abc.abstractproperty
+
+# Regular expression matching correct type alias names. If left empty, type
+# alias names will be checked with the set naming style.
+#typealias-rgx=
+
+# Regular expression matching correct type variable names. If left empty, type
+# variable names will be checked with the set naming style.
+#typevar-rgx=
+
+# Naming style matching correct variable names.
+variable-naming-style=snake_case
+
+# Regular expression matching correct variable names. Overrides variable-
+# naming-style. If left empty, variable names will be checked with the set
+# naming style.
+#variable-rgx=
+
+
+[CLASSES]
+
+# Warn about protected attribute access inside special methods
+check-protected-access-in-special-methods=no
+
+# List of method names used to declare (i.e. assign) instance attributes.
+defining-attr-methods=__init__,
+ __new__,
+ setUp,
+ asyncSetUp,
+ __post_init__
+
+# List of member names, which should be excluded from the protected access
+# warning.
+exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit
+
+# List of valid names for the first argument in a class method.
+valid-classmethod-first-arg=cls
+
+# List of valid names for the first argument in a metaclass class method.
+valid-metaclass-classmethod-first-arg=mcs
+
+
+[DESIGN]
+
+# List of regular expressions of class ancestor names to ignore when counting
+# public methods (see R0903)
+exclude-too-few-public-methods=
+
+# List of qualified class names to ignore when counting class parents (see
+# R0901)
+ignored-parents=
+
+# Maximum number of arguments for function / method.
+max-args=5
+
+# Maximum number of attributes for a class (see R0902).
+max-attributes=7
+
+# Maximum number of boolean expressions in an if statement (see R0916).
+max-bool-expr=5
+
+# Maximum number of branch for function / method body.
+max-branches=12
+
+# Maximum number of locals for function / method body.
+max-locals=15
+
+# Maximum number of parents for a class (see R0901).
+max-parents=7
+
+# Maximum number of public methods for a class (see R0904).
+max-public-methods=20
+
+# Maximum number of return / yield for function / method body.
+max-returns=6
+
+# Maximum number of statements in function / method body.
+max-statements=50
+
+# Minimum number of public methods for a class (see R0903).
+min-public-methods=2
+
+
+[EXCEPTIONS]
+
+# Exceptions that will emit a warning when caught.
+overgeneral-exceptions=builtins.BaseException,builtins.Exception
+
+
+[FORMAT]
+
+# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
+expected-line-ending-format=
+
+# Regexp for a line that is allowed to be longer than the limit.
+ignore-long-lines=^\s*(# )?<?https?://\S+>?$
+
+# Number of spaces of indent required inside a hanging or continued line.
+indent-after-paren=4
+
+# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
+# tab).
+indent-string=' '
+
+# Maximum number of characters on a single line.
+max-line-length=100
+
+# Maximum number of lines in a module.
+max-module-lines=1000
+
+# Allow the body of a class to be on the same line as the declaration if body
+# contains single statement.
+single-line-class-stmt=no
+
+# Allow the body of an if to be on the same line as the test if there is no
+# else.
+single-line-if-stmt=no
+
+
+[IMPORTS]
+
+# List of modules that can be imported at any level, not just the top level
+# one.
+allow-any-import-level=
+
+# Allow explicit reexports by alias from a package __init__.
+allow-reexport-from-package=no
+
+# Allow wildcard imports from modules that define __all__.
+allow-wildcard-with-all=no
+
+# Deprecated modules which should not be used, separated by a comma.
+deprecated-modules=
+
+# Output a graph (.gv or any supported image format) of external dependencies
+# to the given file (report RP0402 must not be disabled).
+ext-import-graph=
+
+# Output a graph (.gv or any supported image format) of all (i.e. internal and
+# external) dependencies to the given file (report RP0402 must not be
+# disabled).
+import-graph=
+
+# Output a graph (.gv or any supported image format) of internal dependencies
+# to the given file (report RP0402 must not be disabled).
+int-import-graph=
+
+# Force import order to recognize a module as part of the standard
+# compatibility libraries.
+known-standard-library=
+
+# Force import order to recognize a module as part of a third party library.
+known-third-party=enchant
+
+# Couples of modules and preferred modules, separated by a comma.
+preferred-modules=
+
+
+[LOGGING]
+
+# The type of string formatting that logging methods do. `old` means using %
+# formatting, `new` is for `{}` formatting.
+logging-format-style=old
+
+# Logging modules to check that the string format arguments are in logging
+# function parameter format.
+logging-modules=logging
+
+
+[MESSAGES CONTROL]
+
+# Only show warnings with the listed confidence levels. Leave empty to show
+# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE,
+# UNDEFINED.
+confidence=HIGH,
+ CONTROL_FLOW,
+ INFERENCE,
+ INFERENCE_FAILURE,
+ UNDEFINED
+
+# Disable the message, report, category or checker with the given id(s). You
+# can either give multiple identifiers separated by comma (,) or put this
+# option multiple times (only on the command line, not in the configuration
+# file where it should appear only once). You can also use "--disable=all" to
+# disable everything first and then re-enable specific checks. For example, if
+# you want to run only the similarities checker, you can use "--disable=all
+# --enable=similarities". If you want to run only the classes checker, but have
+# no Warning level messages displayed, use "--disable=all --enable=classes
+# --disable=W".
+disable=raw-checker-failed,
+ bad-inline-option,
+ locally-disabled,
+ file-ignored,
+ suppressed-message,
+ useless-suppression,
+ deprecated-pragma,
+ use-symbolic-message-instead,
+ use-implicit-booleaness-not-comparison-to-string,
+ use-implicit-booleaness-not-comparison-to-zero,
+ missing-module-docstring,
+ missing-class-docstring,
+ missing-function-docstring,
+ W0122, # Use of exec (exec-used)
+ R0914, # Too many local variables (19/15) (too-many-locals)
+ R0903, # Too few public methods (1/2)
+ W0613, # Unused argument
+ W0511, # TODO
+ W0719, # Raising too general exception: Exception
+ R0801, # Similar lines
+ W0105, # String statement has no effect (pointless-string-statement)
+ R0913, # Too many arguments (6/5) (too-many-arguments)
+ C0415, # Import outside toplevel
+ R0902 # Too many instance attributes (11/7)
+# Enable the message, report, category or checker with the given id(s). You can
+# either give multiple identifier separated by comma (,) or put this option
+# multiple time (only on the command line, not in the configuration file where
+# it should appear only once). See also the "--disable" option for examples.
+enable=
+
+
+[METHOD_ARGS]
+
+# List of qualified names (i.e., library.method) which require a timeout
+# parameter e.g. 'requests.api.get,requests.api.post'
+timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request
+
+
+[MISCELLANEOUS]
+
+# List of note tags to take in consideration, separated by a comma.
+notes=FIXME,
+ XXX,
+ TODO
+
+# Regular expression of note tags to take in consideration.
+notes-rgx=
+
+
+[REFACTORING]
+
+# Maximum number of nested blocks for function / method body
+max-nested-blocks=5
+
+# Complete name of functions that never returns. When checking for
+# inconsistent-return-statements if a never returning function is called then
+# it will be considered as an explicit return statement and no message will be
+# printed.
+never-returning-functions=sys.exit,argparse.parse_error
+
+
+[REPORTS]
+
+# Python expression which should return a score less than or equal to 10. You
+# have access to the variables 'fatal', 'error', 'warning', 'refactor',
+# 'convention', and 'info' which contain the number of messages in each
+# category, as well as 'statement' which is the total number of statements
+# analyzed. This score is used by the global evaluation report (RP0004).
+evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning +
refactor + convention) / statement) * 10))
+
+# Template used to display messages. This is a python new-style format string
+# used to format the message information. See doc for all details.
+msg-template=
+
+# Set the output format. Available formats are: text, parseable, colorized,
+# json2 (improved json format), json (old json format) and msvs (visual
+# studio). You can also give a reporter class, e.g.
+# mypackage.mymodule.MyReporterClass.
+#output-format=
+
+# Tells whether to display a full report or only the messages.
+reports=no
+
+# Activate the evaluation score.
+score=yes
+
+
+[SIMILARITIES]
+
+# Comments are removed from the similarity computation
+ignore-comments=yes
+
+# Docstrings are removed from the similarity computation
+ignore-docstrings=yes
+
+# Imports are removed from the similarity computation
+ignore-imports=yes
+
+# Signatures are removed from the similarity computation
+ignore-signatures=yes
+
+# Minimum lines number of a similarity.
+min-similarity-lines=4
+
+
+[SPELLING]
+
+# Limits count of emitted suggestions for spelling mistakes.
+max-spelling-suggestions=4
+
+# Spelling dictionary name. No available dictionaries : You need to install
+# both the python package and the system dependency for enchant to work.
+spelling-dict=
+
+# List of comma separated words that should be considered directives if they
+# appear at the beginning of a comment and should not be checked.
+spelling-ignore-comment-directives=fmt: on,fmt:
off,noqa:,noqa,nosec,isort:skip,mypy:
+
+# List of comma separated words that should not be checked.
+spelling-ignore-words=
+
+# A path to a file that contains the private dictionary; one word per line.
+spelling-private-dict-file=
+
+# Tells whether to store unknown words to the private dictionary (see the
+# --spelling-private-dict-file option) instead of raising a message.
+spelling-store-unknown-words=no
+
+
+[STRING]
+
+# This flag controls whether inconsistent-quotes generates a warning when the
+# character used as a quote delimiter is used inconsistently within a module.
+check-quote-consistency=no
+
+# This flag controls whether the implicit-str-concat should generate a warning
+# on implicit string concatenation in sequences defined over several lines.
+check-str-concat-over-line-jumps=no
+
+
+[TYPECHECK]
+
+# List of decorators that produce context managers, such as
+# contextlib.contextmanager. Add to this list to register other decorators that
+# produce valid context managers.
+contextmanager-decorators=contextlib.contextmanager
+
+# List of members which are set dynamically and missed by pylint inference
+# system, and so shouldn't trigger E1101 when accessed. Python regular
+# expressions are accepted.
+generated-members=
+
+# Tells whether to warn about missing members when the owner of the attribute
+# is inferred to be None.
+ignore-none=yes
+
+# This flag controls whether pylint should warn about no-member and similar
+# checks whenever an opaque object is returned when inferring. The inference
+# can return multiple potential results while evaluating a Python object, but
+# some branches might not be evaluated, which results in partial inference. In
+# that case, it might be useful to still emit no-member and other checks for
+# the rest of the inferred objects.
+ignore-on-opaque-inference=yes
+
+# List of symbolic message names to ignore for Mixin members.
+ignored-checks-for-mixins=no-member,
+ not-async-context-manager,
+ not-context-manager,
+ attribute-defined-outside-init
+
+# List of class names for which member attributes should not be checked (useful
+# for classes with dynamically set attributes). This supports the use of
+# qualified names.
+ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace
+
+# Show a hint with possible names when a member name was not found. The aspect
+# of finding the hint is based on edit distance.
+missing-member-hint=yes
+
+# The minimum edit distance a name should have in order to be considered a
+# similar match for a missing member name.
+missing-member-hint-distance=1
+
+# The total number of similar names that should be taken in consideration when
+# showing a hint for a missing member.
+missing-member-max-choices=1
+
+# Regex pattern to define which classes are considered mixins.
+mixin-class-rgx=.*[Mm]ixin
+
+# List of decorators that change the signature of a decorated function.
+signature-mutators=
+
+
+[VARIABLES]
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid defining new builtins when possible.
+additional-builtins=
+
+# Tells whether unused global variables should be treated as a violation.
+allow-global-unused-variables=yes
+
+# List of names allowed to shadow builtins
+allowed-redefined-builtins=
+
+# List of strings which can identify a callback function by name. A callback
+# name must start or end with one of those strings.
+callbacks=cb_,
+ _cb
+
+# A regular expression matching the name of dummy variables (i.e. expected to
+# not be used).
+dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
+
+# Argument names that match this expression will be ignored.
+ignored-argument-names=_.*|^ignored_|^unused_
+
+# Tells whether we should check for unused import in __init__ files.
+init-import=no
+
+# List of qualified module names which can have objects that can redefine
+# builtins.
+redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io