Merge repeated if statements into single if
This commit is contained in:
@@ -100,11 +100,8 @@ class Command:
|
||||
return ret
|
||||
|
||||
async def history(self):
|
||||
ret = []
|
||||
versions = Migrate.get_all_version_files()
|
||||
for version in versions:
|
||||
ret.append(version)
|
||||
return ret
|
||||
return [version for version in versions]
|
||||
|
||||
async def inspectdb(self, tables: List[str]):
|
||||
connection = get_app_connection(self.tortoise_config, self.app)
|
||||
|
||||
@@ -184,7 +184,7 @@ class BaseDDL:
|
||||
"idx" if not unique else "uid", model, field_names
|
||||
),
|
||||
table_name=model._meta.db_table,
|
||||
column_names=", ".join([self.schema_generator.quote(f) for f in field_names]),
|
||||
column_names=", ".join(self.schema_generator.quote(f) for f in field_names),
|
||||
)
|
||||
|
||||
def drop_index(self, model: "Type[Model]", field_names: List[str], unique=False):
|
||||
|
||||
@@ -96,11 +96,10 @@ def get_version_content_from_file(version_file: Union[str, Path]) -> Dict:
|
||||
second = len(content) - 1
|
||||
upgrade_content = content[first + len(_UPGRADE) : second].strip() # noqa:E203
|
||||
downgrade_content = content[second + len(_DOWNGRADE) :].strip() # noqa:E203
|
||||
ret = {
|
||||
return {
|
||||
"upgrade": list(filter(lambda x: x or False, upgrade_content.split(";\n"))),
|
||||
"downgrade": list(filter(lambda x: x or False, downgrade_content.split(";\n"))),
|
||||
}
|
||||
return ret
|
||||
|
||||
|
||||
def write_version_file(version_file: Path, content: Dict):
|
||||
|
||||
Reference in New Issue
Block a user