Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored main branch #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Nov 30, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

# HTML table header
html = '<table><tr><th>'
html += '</th><th>'.join(columns)
html = '<table><tr><th>' + '</th><th>'.join(columns)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function table_print refactored with the following changes:

This removes the following comments ( why? ):

# HTML table header

Comment on lines -550 to -553
results = self._redis_conn.ft(self._name).search( # type: ignore
return self._redis_conn.ft(self._name).search( # type: ignore
*args, **kwargs
)
return results
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SearchIndex.search refactored with the following changes:

Comment on lines -778 to +777
results = await self._redis_conn.ft(self._name).search(*args, **kwargs) # type: ignore
return results
return await self._redis_conn.ft(self._name).search(*args, **kwargs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AsyncSearchIndex.search refactored with the following changes:

This removes the following comments ( why? ):

# type: ignore

for field in field_group:
redis_fields.append(field.as_field())
redis_fields.extend(field.as_field() for field in field_group)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SchemaModel.index_fields refactored with the following changes:

Comment on lines -235 to +234
field_class = field_classes.get(field_type)
if field_class:
if field_class := field_classes.get(field_type):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SchemaGenerator.generate refactored with the following changes:

Comment on lines -231 to -242
_filter = "*"
if self._filter:
_filter = str(self._filter)
_filter = str(self._filter) if self._filter else "*"
base_query = f"{_filter}=>[KNN {self._num_results} @{self._field} ${self.VECTOR_PARAM} AS {self.DISTANCE_ID}]"
query = (
return (
Query(base_query)
.return_fields(*self._return_fields)
.sort_by(self.DISTANCE_ID)
.paging(0, self._num_results)
.dialect(2)
)
return query
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function VectorQuery.query refactored with the following changes:

Comment on lines -332 to +331
_filter = "*"
if self._filter:
_filter = str(self._filter)

_filter = str(self._filter) if self._filter else "*"
# Avoid appending a filter that yields '*' as it will cause a syntax error in Redis query language
if _filter != "*":
base_query = (
"("
+ base_query
f"({base_query}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RangeQuery.query refactored with the following changes:

Comment on lines -39 to -42
addr = os.getenv("REDIS_URL", None)
if not addr:
if addr := os.getenv("REDIS_URL", None):
return addr
else:
raise ValueError("REDIS_URL env var not set")
return addr
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_address_from_env refactored with the following changes:

if isinstance(data, tuple):
return map(convert_bytes, data)
return data
return map(convert_bytes, data) if isinstance(data, tuple) else data
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function convert_bytes refactored with the following changes:

if as_buffer:
return array_to_buffer(embedding)
return embedding
return array_to_buffer(embedding) if as_buffer else embedding
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BaseVectorizer._process_embedding refactored with the following changes:

if len(texts) > 0 and not isinstance(texts[0], str):
if texts and not isinstance(texts[0], str):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function HFTextVectorizer.embed_many refactored with the following changes:

if len(texts) > 0 and not isinstance(texts[0], str):
if texts and not isinstance(texts[0], str):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function OpenAITextVectorizer.embed_many refactored with the following changes:

if len(texts) > 0 and not isinstance(texts[0], str):
if texts and not isinstance(texts[0], str):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function OpenAITextVectorizer.aembed_many refactored with the following changes:

if len(texts) > 0 and not isinstance(texts[0], str):
if texts and not isinstance(texts[0], str):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function VertexAITextVectorizer.embed_many refactored with the following changes:

assert int(doc.age) in [18, 14, 94, 100, 12, 15, 35]
assert int(doc.age) in {18, 14, 94, 100, 12, 15, 35}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_simple refactored with the following changes:

users = [doc for doc in results.docs]
users = list(results.docs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_simple refactored with the following changes:

tag = Tag("tag_field") == None
tag = Tag("tag_field") is None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_nullable refactored with the following changes:

nf = Num("numeric_field") == None
nf = Num("numeric_field") is None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_numeric_filter refactored with the following changes:

Comment on lines -247 to +259
tf1 = Tag("tag_field") == None
tf1 = Tag("tag_field") is None
tf2 = Tag("tag_field") == ""
assert str(tf1 & tf2) == "*"

tf1 = Tag("tag_field") == None
tf1 = Tag("tag_field") is None
tf2 = Tag("tag_field") == "tag"
assert str(tf1 & tf2) == str(tf2)

tf1 = Tag("tag_field") == None
tf1 = Tag("tag_field") is None
tf2 = Tag("tag_field") == ["tag1", "tag2"]
assert str(tf1 & tf2) == str(tf2)

tf1 = Tag("tag_field") == None
tf1 = Tag("tag_field") is None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_filters_combination refactored with the following changes:

instance = StorageClass(prefix="test", key_separator=":")
return instance
return StorageClass(prefix="test", key_separator=":")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function storage_instance refactored with the following changes:

@pep8speaks
Copy link

Hello @sourcery-ai[bot]! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 504:80: E501 line too long (86 > 79 characters)

Line 43:80: E501 line too long (81 > 79 characters)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants