Skip to content

Commit 6570bfc

Browse files
chore: additional Python syntax modernization with pyupgrade
Co-Authored-By: Aaron <AJ> Steers <[email protected]>
1 parent d50f14d commit 6570bfc

File tree

13 files changed

+20
-23
lines changed

13 files changed

+20
-23
lines changed

airbyte_cdk/config_observation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __setitem__(self, item: Any, value: Any) -> None:
5757
for i, sub_value in enumerate(value):
5858
if isinstance(sub_value, MutableMapping):
5959
value[i] = ObservedDict(sub_value, self.observer)
60-
super(ObservedDict, self).__setitem__(item, value)
60+
super().__setitem__(item, value)
6161
if self.update_on_unchanged_value or value != previous_value:
6262
self.observer.update()
6363

airbyte_cdk/sources/declarative/concurrent_declarative_source.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ def read(
142142
# the concurrent streams must be saved so that they can be removed from the catalog before starting
143143
# synchronous streams
144144
if len(concurrent_streams) > 0:
145-
concurrent_stream_names = set(
146-
[concurrent_stream.name for concurrent_stream in concurrent_streams]
147-
)
145+
concurrent_stream_names = {
146+
concurrent_stream.name for concurrent_stream in concurrent_streams
147+
}
148148

149149
selected_concurrent_streams = self._select_streams(
150150
streams=concurrent_streams, configured_catalog=catalog

airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ def parse(self, data: BufferedIOBase) -> PARSER_OUTPUT_TYPE:
120120
"""
121121
text_data = TextIOWrapper(data, encoding=self.encoding) # type: ignore
122122
reader = csv.DictReader(text_data, delimiter=self._get_delimiter() or ",")
123-
for row in reader:
124-
yield row
123+
yield from reader
125124

126125

127126
class CompositeRawDecoder(Decoder):

airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ def _read_with_chunks(
142142
)
143143
for chunk in chunks:
144144
chunk = chunk.replace({nan: None}).to_dict(orient="records")
145-
for row in chunk:
146-
yield row
145+
yield from chunk
147146
except pd.errors.EmptyDataError as e:
148147
self.logger.info(f"Empty data received. {e}")
149148
yield from []

airbyte_cdk/sources/file_based/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def collect(self, logged_error: AirbyteMessage) -> None:
6363

6464

6565
class BaseFileBasedSourceError(Exception):
66-
def __init__(self, error: Union[FileBasedSourceError, str], **kwargs): # type: ignore # noqa
66+
def __init__(self, error: FileBasedSourceError | str, **kwargs): # type: ignore # noqa
6767
if isinstance(error, FileBasedSourceError):
6868
error = FileBasedSourceError(error).value
6969
super().__init__(

airbyte_cdk/sql/shared/sql_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def get_sql_engine(self) -> Engine:
210210
return self.sql_config.get_sql_engine()
211211

212212
@contextmanager
213-
def get_sql_connection(self) -> Generator[sqlalchemy.engine.Connection, None, None]:
213+
def get_sql_connection(self) -> Generator[sqlalchemy.engine.Connection]:
214214
"""A context manager which returns a new SQL connection for running queries.
215215
216216
If the connection needs to close, it will be closed automatically.

airbyte_cdk/utils/schema_inferrer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class NoRequiredObj(Object):
3232
"""
3333

3434
def to_schema(self) -> Mapping[str, Any]:
35-
schema: dict[str, Any] = super(NoRequiredObj, self).to_schema()
35+
schema: dict[str, Any] = super().to_schema()
3636
schema.pop("required", None)
3737
return schema
3838

unit_tests/sources/declarative/interpolation/test_filters.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_hash_md5_with_salt() -> None:
4242
input_string = "test_input_string"
4343
input_salt = "test_input_salt"
4444

45-
s = "{{ '%s' | hash('md5', '%s' ) }}" % (input_string, input_salt)
45+
s = "{{{{ '{}' | hash('md5', '{}' ) }}}}".format(input_string, input_salt)
4646
filter_hash = interpolation.eval(s, config={})
4747

4848
# compute expected value calling hashlib directly
@@ -112,7 +112,7 @@ def test_hmac_sha256_default() -> None:
112112
message = "test_message"
113113
secret_key = "test_secret_key"
114114

115-
s = "{{ '%s' | hmac('%s') }}" % (message, secret_key)
115+
s = "{{{{ '{}' | hmac('{}') }}}}".format(message, secret_key)
116116
filter_hmac = interpolation.eval(s, config={})
117117

118118
# compute expected hmac using the hmac library directly
@@ -128,7 +128,7 @@ def test_hmac_sha256_explicit() -> None:
128128
message = "test_message"
129129
secret_key = "test_secret_key"
130130

131-
s = "{{ '%s' | hmac('%s', 'sha256') }}" % (message, secret_key)
131+
s = "{{{{ '{}' | hmac('{}', 'sha256') }}}}".format(message, secret_key)
132132
filter_hmac = interpolation.eval(s, config={})
133133

134134
# compute expected hmac using the hmac library directly
@@ -160,7 +160,7 @@ def test_hmac_with_invalid_hash_type() -> None:
160160
message = "test_message"
161161
secret_key = "test_secret_key"
162162

163-
s = "{{ '%s' | hmac('%s', 'md5') }}" % (message, secret_key)
163+
s = "{{{{ '{}' | hmac('{}', 'md5') }}}}".format(message, secret_key)
164164

165165
with pytest.raises(ValueError):
166166
interpolation.eval(s, config={})

unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_time_from_header.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
),
4040
("test_wait_time_from_header_not_a_number", "wait_time", "61,60", None, None),
4141
("test_wait_time_from_header_with_regex", "wait_time", "61,60", r"([-+]?\d+)", 61), # noqa
42-
("test_wait_time_fœrom_header_with_regex_no_match", "wait_time", "...", "[-+]?\d+", None), # noqa
42+
("test_wait_time_fœrom_header_with_regex_no_match", "wait_time", "...", r"[-+]?\d+", None), # noqa
4343
("test_wait_time_from_header", "absent_header", None, None, None),
4444
],
4545
)

unit_tests/sources/declarative/requesters/error_handlers/backoff_strategies/test_wait_until_time_from_header.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"wait_until",
5454
"1600000060,60",
5555
None,
56-
"[-+]?\d+",
56+
r"[-+]?\d+",
5757
60,
5858
), # noqa
5959
(
@@ -78,7 +78,7 @@
7878
"wait_time",
7979
"...",
8080
None,
81-
"[-+]?\d+",
81+
r"[-+]?\d+",
8282
None,
8383
), # noqa
8484
(

0 commit comments

Comments
 (0)