Skip to content

Commit f27557e

Browse files
chore: Enable RET Ruff rule (#441)
1 parent 878606e commit f27557e

File tree

3 files changed

+21
-30
lines changed

3 files changed

+21
-30
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ select = [
9292
"I", # isort
9393
"N", # pep8-naming
9494
"D", # pydocsyle
95-
"ICN", # flake8-import-conventions
9695
"UP", # pyupgrade
96+
"ICN", # flake8-import-conventions
97+
"RET", # flake8-return
9798
"RUF", # ruff
9899
]
99100

target_postgres/connector.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,9 @@ def copy_table_structure(
187187
new_table = sa.Table(table_name, meta, *columns, prefixes=["TEMPORARY"])
188188
new_table.create(bind=connection)
189189
return new_table
190-
else:
191-
new_table = sa.Table(table_name, meta, *columns)
192-
new_table.create(bind=connection)
193-
return new_table
190+
new_table = sa.Table(table_name, meta, *columns)
191+
new_table.create(bind=connection)
192+
return new_table
194193

195194
@contextmanager
196195
def _connect(self) -> t.Iterator[sa.engine.Connection]:
@@ -653,17 +652,16 @@ def get_sqlalchemy_url(self, config: dict) -> str:
653652
if config.get("sqlalchemy_url"):
654653
return cast(str, config["sqlalchemy_url"])
655654

656-
else:
657-
sqlalchemy_url = URL.create(
658-
drivername=config["dialect+driver"],
659-
username=config["user"],
660-
password=config["password"],
661-
host=config["host"],
662-
port=config["port"],
663-
database=config["database"],
664-
query=self.get_sqlalchemy_query(config),
665-
)
666-
return cast(str, sqlalchemy_url)
655+
sqlalchemy_url = URL.create(
656+
drivername=config["dialect+driver"],
657+
username=config["user"],
658+
password=config["password"],
659+
host=config["host"],
660+
port=config["port"],
661+
database=config["database"],
662+
query=self.get_sqlalchemy_query(config),
663+
)
664+
return cast(str, sqlalchemy_url)
667665

668666
def get_sqlalchemy_query(self, config: dict) -> dict:
669667
"""Get query values to be used for sqlalchemy URL creation.
@@ -725,12 +723,11 @@ def filepath_or_certificate(
725723
"""
726724
if path.isfile(value):
727725
return value
728-
else:
729-
with open(alternative_name, "wb") as alternative_file:
730-
alternative_file.write(value.encode("utf-8"))
731-
if restrict_permissions:
732-
chmod(alternative_name, 0o600)
733-
return alternative_name
726+
with open(alternative_name, "wb") as alternative_file:
727+
alternative_file.write(value.encode("utf-8"))
728+
if restrict_permissions:
729+
chmod(alternative_name, 0o600)
730+
return alternative_name
734731

735732
def guess_key_type(self, key_data: str) -> paramiko.PKey:
736733
"""Guess the type of the private key.

target_postgres/sinks.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,7 @@ def schema_name(self) -> str | None:
307307
if default_target_schema:
308308
return default_target_schema
309309

310-
if len(parts) in {2, 3}:
311-
# Stream name is a two-part or three-part identifier.
312-
# Use the second-to-last part as the schema name.
313-
stream_schema = self.conform_name(parts[-2], "schema")
314-
return stream_schema
315-
316-
# Schema name not detected.
317-
return None
310+
return self.conform_name(parts[-2], "schema") if len(parts) in {2, 3} else None
318311

319312
def activate_version(self, new_version: int) -> None:
320313
"""Bump the active version of the target table.

0 commit comments

Comments
 (0)