Skip to content

Commit 16792df

Browse files
enable SIM108
1 parent 4f1bc3e commit 16792df

File tree

9 files changed

+15
-43
lines changed

9 files changed

+15
-43
lines changed

metadata-ingestion/pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ extend-ignore = [
4646
"SIM102", # Use a single `if` statement instead of nested `if` statements
4747
"SIM103", # Return the condition directly
4848
"SIM105", # Use `contextlib.suppress(...)` instead of `try`-`except`-`pass`
49-
"SIM108", # Use ternary operator {contents} instead of if-else-block
5049
"SIM115", # Use a context manager for opening files
5150
"SIM116", # Use a dictionary instead of consecutive `if` statements
5251
"SIM117", # Use a single with statement with multiple contexts instead of nested with statements

metadata-ingestion/src/datahub/configuration/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class PermissiveConfigModel(ConfigModel):
130130
# It is usually used for argument bags that are passed through to third-party libraries.
131131

132132
class Config:
133-
if PYDANTIC_VERSION_2:
133+
if PYDANTIC_VERSION_2: # noqa: SIM108
134134
extra = "allow"
135135
else:
136136
extra = Extra.allow

metadata-ingestion/src/datahub/ingestion/source/dbt/dbt_common.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1774,10 +1774,8 @@ def _aggregate_owners(
17741774
logger.debug(
17751775
f"Owner after applying owner extraction pattern:'{self.config.owner_extraction_pattern}' is '{owner}'."
17761776
)
1777-
if isinstance(owner, list):
1778-
owners = owner
1779-
else:
1780-
owners = [owner]
1777+
owners = owner if isinstance(owner, list) else [owner]
1778+
17811779
for owner in owners:
17821780
if self.config.strip_user_ids_from_email:
17831781
owner = owner.split("@")[0]

metadata-ingestion/src/datahub/ingestion/source/dbt/dbt_tests.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,11 @@ def _get_name_for_relationship_test(kw_args: Dict[str, str]) -> Optional[str]:
5757
# base assertions are violated, bail early
5858
return None
5959
m = re.match(r"^ref\(\'(.*)\'\)$", destination_ref)
60-
if m:
61-
destination_table = m.group(1)
62-
else:
63-
destination_table = destination_ref
60+
destination_table = m.group(1) if m else destination_ref
61+
6462
m = re.search(r"ref\(\'(.*)\'\)", source_ref)
65-
if m:
66-
source_table = m.group(1)
67-
else:
68-
source_table = source_ref
63+
source_table = m.group(1) if m else source_ref
64+
6965
return f"{source_table}.{column_name} referential integrity to {destination_table}.{dest_field_name}"
7066

7167

metadata-ingestion/src/datahub/ingestion/source/dremio/dremio_aspects.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ def get_field_type(
116116
data_type = data_type.lower()
117117
type_class = cls.FIELD_TYPE_MAPPING.get(data_type, NullTypeClass)
118118

119-
if data_size:
120-
native_data_type = f"{data_type}({data_size})"
121-
else:
122-
native_data_type = data_type
119+
native_data_type = f"{data_type}({data_size})" if data_size else data_type
123120

124121
try:
125122
schema_field_type = SchemaFieldDataTypeClass(type=type_class())

metadata-ingestion/src/datahub/ingestion/source/kafka_connect/common.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,7 @@ def get_dataset_name(
141141
database_name: Optional[str],
142142
source_table: str,
143143
) -> str:
144-
if database_name:
145-
dataset_name = database_name + "." + source_table
146-
else:
147-
dataset_name = source_table
148-
149-
return dataset_name
144+
return database_name + "." + source_table if database_name else source_table
150145

151146

152147
def get_platform_instance(

metadata-ingestion/src/datahub/ingestion/source/sql/hive.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -821,12 +821,8 @@ def _process_view(
821821

822822
try:
823823
view_definition = inspector.get_view_definition(view, schema)
824-
if view_definition is None:
825-
view_definition = ""
826-
else:
827-
# Some dialects return a TextClause instead of a raw string,
828-
# so we need to convert them to a string.
829-
view_definition = str(view_definition)
824+
# Some dialects return a TextClause instead of a raw string, so we need to convert them to a string.
825+
view_definition = str(view_definition) if view_definition else ""
830826
except NotImplementedError:
831827
view_definition = ""
832828

metadata-ingestion/src/datahub/ingestion/source/sql/sql_common.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -1031,16 +1031,10 @@ def loop_views(
10311031
def _get_view_definition(self, inspector: Inspector, schema: str, view: str) -> str:
10321032
try:
10331033
view_definition = inspector.get_view_definition(view, schema)
1034-
if view_definition is None:
1035-
view_definition = ""
1036-
else:
1037-
# Some dialects return a TextClause instead of a raw string,
1038-
# so we need to convert them to a string.
1039-
view_definition = str(view_definition)
1034+
# Some dialects return a TextClause instead of a raw string, so we need to convert them to a string.
1035+
return str(view_definition) if view_definition else ""
10401036
except NotImplementedError:
1041-
view_definition = ""
1042-
1043-
return view_definition
1037+
return ""
10441038

10451039
def _process_view(
10461040
self,

metadata-ingestion/src/datahub/sql_parsing/sqlglot_utils.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ def get_dialect(platform: DialectOrStr) -> sqlglot.Dialect:
5656
def is_dialect_instance(
5757
dialect: sqlglot.Dialect, platforms: Union[str, Iterable[str]]
5858
) -> bool:
59-
if isinstance(platforms, str):
60-
platforms = [platforms]
61-
else:
62-
platforms = list(platforms)
59+
platforms = [platforms] if isinstance(platforms, str) else list(platforms)
6360

6461
dialects = [get_dialect(platform) for platform in platforms]
6562

0 commit comments

Comments
 (0)