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 master branch #2

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

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Sep 28, 2023

Branch master 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 master branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from suoaao September 28, 2023 19:55
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -181 to +185
modifier="{} ".format(" ".join(self._modifiers)) if self._modifiers else "",
select=",".join(term.get_sql(with_alias=True, subquery=True, **kwargs) for term in self._selects),
modifier=f'{" ".join(self._modifiers)} ' if self._modifiers else "",
select=",".join(
term.get_sql(with_alias=True, subquery=True, **kwargs)
for term in self._selects
),
Copy link
Author

Choose a reason for hiding this comment

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

Function MySQLQueryBuilder._select_sql refactored with the following changes:

Comment on lines -211 to +214
return "LOAD DATA LOCAL INFILE '{}'".format(self._load_file)
return f"LOAD DATA LOCAL INFILE '{self._load_file}'"
Copy link
Author

Choose a reason for hiding this comment

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

Function MySQLLoadQueryBuilder._load_file_sql refactored with the following changes:

Comment on lines -341 to +344
return " FROM LOCAL '{}'".format(self._from_file)
return f" FROM LOCAL '{self._from_file}'"
Copy link
Author

Choose a reason for hiding this comment

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

Function VerticaCopyQueryBuilder._from_file_sql refactored with the following changes:

Comment on lines -757 to +760
def drop_database(self, database: Union[Database, str]) -> "ClickHouseDropQueryBuilder":
def drop_database(cls, database: Union[Database, str]) -> "ClickHouseDropQueryBuilder":
Copy link
Author

Choose a reason for hiding this comment

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

Function ClickHouseQuery.drop_database refactored with the following changes:

Comment on lines -761 to +764
def drop_table(self, table: Union[Table, str]) -> "ClickHouseDropQueryBuilder":
def drop_table(cls, table: Union[Table, str]) -> "ClickHouseDropQueryBuilder":
Copy link
Author

Choose a reason for hiding this comment

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

Function ClickHouseQuery.drop_table refactored with the following changes:

Comment on lines -191 to +187
if self._schema != other._schema:
return False

if self.alias != other.alias:
return False

return True
return False if self._schema != other._schema else self.alias == other.alias
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.__eq__ refactored with the following changes:

Comment on lines -201 to +192
return "Table('{}', schema='{}')".format(self._table_name, self._schema)
return "Table('{}')".format(self._table_name)
return f"Table('{self._table_name}', schema='{self._schema}')"
return f"Table('{self._table_name}')"
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.__repr__ refactored with the following changes:

Comment on lines -288 to -292
column_sql = "{name}".format(
return "{name}".format(
name=format_quotes(self.name, quote_char),
)

return column_sql
Copy link
Author

Choose a reason for hiding this comment

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

Function Column.get_name_sql refactored with the following changes:

Comment on lines -295 to -302
column_sql = "{name}{type}{nullable}{default}".format(
return "{name}{type}{nullable}{default}".format(
name=self.get_name_sql(**kwargs),
type=" {}".format(self.type) if self.type else "",
nullable=" {}".format("NULL" if self.nullable else "NOT NULL") if self.nullable is not None else "",
default=" {}".format("DEFAULT " + self.default.get_sql(**kwargs)) if self.default else "",
type=f" {self.type}" if self.type else "",
nullable=f' {"NULL" if self.nullable else "NOT NULL"}'
if self.nullable is not None
else "",
default=" {}".format(f"DEFAULT {self.default.get_sql(**kwargs)}")
if self.default
else "",
)

return column_sql
Copy link
Author

Choose a reason for hiding this comment

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

Function Column.get_sql refactored with the following changes:

Comment on lines -334 to -340
period_for_sql = "PERIOD FOR {name} ({start_column_name},{end_column_name})".format(
return "PERIOD FOR {name} ({start_column_name},{end_column_name})".format(
name=format_quotes(self.name, quote_char),
start_column_name=self.start_column.get_name_sql(**kwargs),
end_column_name=self.end_column.get_name_sql(**kwargs),
)

return period_for_sql
Copy link
Author

Choose a reason for hiding this comment

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

Function PeriodFor.get_sql refactored with the following changes:

Comment on lines -831 to +819
raise AttributeError("'Query' object has no attribute '%s'" % "into")
raise AttributeError("'Query' object has no attribute 'into'")
Copy link
Author

Choose a reason for hiding this comment

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

Function QueryBuilder.into refactored with the following changes:

Comment on lines -853 to +841
raise AttributeError("'Query' object has no attribute '%s'" % "delete")
raise AttributeError("'Query' object has no attribute 'delete'")
Copy link
Author

Choose a reason for hiding this comment

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

Function QueryBuilder.delete refactored with the following changes:

Comment on lines -860 to +848
raise AttributeError("'Query' object has no attribute '%s'" % "update")
raise AttributeError("'Query' object has no attribute 'update'")
Copy link
Author

Choose a reason for hiding this comment

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

Function QueryBuilder.update refactored with the following changes:

Comment on lines -867 to +855
raise AttributeError("'Query' object has no attribute '%s'" % "insert")
raise AttributeError("'Query' object has no attribute 'insert'")
Copy link
Author

Choose a reason for hiding this comment

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

Function QueryBuilder.columns refactored with the following changes:

Comment on lines -964 to +955
for_mysql = "mysql" == kwargs.get("vendor")
for_mysql = kwargs.get("vendor") == "mysql"

if self._mysql_rollup:
raise AttributeError("'Query' object has no attribute '%s'" % "rollup")
raise AttributeError("'Query' object has no attribute 'rollup'")
Copy link
Author

Choose a reason for hiding this comment

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

Function QueryBuilder.rollup refactored with the following changes:

Comment on lines -1631 to +1596
collate=" COLLATE {}".format(self.collate) if self.collate else "",
collate=f" COLLATE {self.collate}" if self.collate else "",
Copy link
Author

Choose a reason for hiding this comment

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

Function JoinOn.get_sql refactored with the following changes:

Comment on lines -1635 to +1602
criterion_tables = set([f.table for f in self.criterion.fields_()])
criterion_tables = {f.table for f in self.criterion.fields_()}
available_tables = set(_from) | {join.item for join in _joins} | {self.item}
missing_tables = criterion_tables - available_tables
if missing_tables:
if missing_tables := criterion_tables - available_tables:
Copy link
Author

Choose a reason for hiding this comment

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

Function JoinOn.validate refactored with the following changes:

Comment on lines -1970 to +1934
if_not_exists = ''
if self._if_not_exists:
if_not_exists = 'IF NOT EXISTS '

if_not_exists = 'IF NOT EXISTS ' if self._if_not_exists else ''
Copy link
Author

Choose a reason for hiding this comment

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

Function CreateQueryBuilder._create_table_sql refactored with the following changes:

Comment on lines -2012 to +1975
clause += " ON DELETE " + self._foreign_key_on_delete.value
clause += f" ON DELETE {self._foreign_key_on_delete.value}"
if self._foreign_key_on_update:
clause += " ON UPDATE " + self._foreign_key_on_update.value
clause += f" ON UPDATE {self._foreign_key_on_update.value}"
Copy link
Author

Choose a reason for hiding this comment

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

Function CreateQueryBuilder._foreign_key_clause refactored with the following changes:

Comment on lines -2100 to +2061
if isinstance(self._drop_target, Database):
target_name = self._drop_target.get_sql(**kwargs)
elif isinstance(self._drop_target, Table):
if isinstance(self._drop_target, (Database, Table)):
Copy link
Author

Choose a reason for hiding this comment

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

Function DropQueryBuilder.get_sql refactored with the following changes:

if value is None:
return "null"
return str(value)
return "null" if value is None else str(value)
Copy link
Author

Choose a reason for hiding this comment

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

Function ValueWrapper.get_formatted_value refactored with the following changes:

Comment on lines -607 to +605
return "{}.*".format(format_quotes(namespace, quote_char))
return f"{format_quotes(namespace, quote_char)}.*"
Copy link
Author

Choose a reason for hiding this comment

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

Function Star.get_sql refactored with the following changes:

sql = "[{}]".format(values)
sql = f"[{values}]"
if dialect in (Dialects.POSTGRESQL, Dialects.REDSHIFT):
sql = "ARRAY[{}]".format(values) if len(values) > 0 else "'{}'"
sql = f"ARRAY[{values}]" if values != "" else "'{}'"
Copy link
Author

Choose a reason for hiding this comment

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

Function Array.get_sql refactored with the following changes:

Comment on lines -770 to +768
if with_alias:
return format_alias_sql(sql, self.alias, **kwargs)
return sql
return format_alias_sql(sql, self.alias, **kwargs) if with_alias else sql
Copy link
Author

Choose a reason for hiding this comment

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

Function BasicCriterion.get_sql refactored with the following changes:

Comment on lines -977 to +973
if subcriterion:
return "({criterion})".format(criterion=sql)

return sql
return "({criterion})".format(criterion=sql) if subcriterion else sql
Copy link
Author

Choose a reason for hiding this comment

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

Function ComplexCriterion.get_sql refactored with the following changes:

self._converter_options = converter_options or dict()
self._converter_options = converter_options or {}
Copy link
Author

Choose a reason for hiding this comment

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

Function Array.__init__ refactored with the following changes:

Comment on lines -52 to +53
left='"%s"' % left if isinstance(self._left_array, Field) else left,
right='"%s"' % right if isinstance(self._right_array, Field) else right,
left=f'"{left}"' if isinstance(self._left_array, Field) else left,
right=f'"{right}"' if isinstance(self._right_array, Field) else right,
Copy link
Author

Choose a reason for hiding this comment

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

Function HasAny.get_sql refactored with the following changes:

array='"%s"' % array if isinstance(self._array, Field) else array,
array=f'"{array}"' if isinstance(self._array, Field) else array,
Copy link
Author

Choose a reason for hiding this comment

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

Function _AbstractArrayFunction.get_sql refactored with the following changes:

patterns=",".join(["'%s'" % i for i in self._patterns]),
patterns=",".join([f"'{i}'" for i in self._patterns]),
Copy link
Author

Choose a reason for hiding this comment

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

Function _AbstractMultiSearchString.get_sql refactored with the following changes:

Comment on lines -25 to +27
field=self._field if isinstance(self._field, Field) else "'%s'" % str(self._field),
field=self._field
if isinstance(self._field, Field)
else f"'{str(self._field)}'",
Copy link
Author

Choose a reason for hiding this comment

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

Function ToFixedString.get_sql refactored with the following changes:

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

Successfully merging this pull request may close these issues.

0 participants