From a096eeba08a98d367e4a19f6d90e5d4e88aa50ff Mon Sep 17 00:00:00 2001 From: Miguel Hernandez Date: Wed, 19 Jan 2022 09:41:26 -0600 Subject: [PATCH 1/3] [BEAM-13051] Pylint no-name-in-module and no-value-for-parameter warnings enabled --- sdks/python/.pylintrc | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdks/python/.pylintrc b/sdks/python/.pylintrc index bead17d76cd7..a5d8e006c6eb 100644 --- a/sdks/python/.pylintrc +++ b/sdks/python/.pylintrc @@ -119,10 +119,8 @@ disable = no-else-raise, no-else-return, no-member, - no-name-in-module, no-self-argument, no-self-use, - no-value-for-parameter, not-callable, pointless-statement, protected-access, From 3ece30137f183a37f0a7265c2b46d191687e6172 Mon Sep 17 00:00:00 2001 From: Miguel Hernandez Date: Fri, 21 Jan 2022 13:54:43 -0600 Subject: [PATCH 2/3] [BEAM-13051] Fixed no-value-for-parameter warning for missing default values --- sdks/python/.pylintrc | 2 ++ sdks/python/apache_beam/io/avroio_test.py | 8 +++++++- sdks/python/apache_beam/io/filesystem.py | 3 +-- .../testing/load_tests/load_test_metrics_utils.py | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sdks/python/.pylintrc b/sdks/python/.pylintrc index a5d8e006c6eb..bead17d76cd7 100644 --- a/sdks/python/.pylintrc +++ b/sdks/python/.pylintrc @@ -119,8 +119,10 @@ disable = no-else-raise, no-else-return, no-member, + no-name-in-module, no-self-argument, no-self-use, + no-value-for-parameter, not-callable, pointless-statement, protected-access, diff --git a/sdks/python/apache_beam/io/avroio_test.py b/sdks/python/apache_beam/io/avroio_test.py index 3d0db805cbf2..bcffac528a19 100644 --- a/sdks/python/apache_beam/io/avroio_test.py +++ b/sdks/python/apache_beam/io/avroio_test.py @@ -95,7 +95,13 @@ def tearDown(self): os.remove(path) self._temp_files = [] - def _write_data(self, directory, prefix, codec, count, sync_interval): + def _write_data( + self, + directory=None, + prefix=None, + codec=None, + count=None, + sync_interval=None): raise NotImplementedError def _write_pattern(self, num_files, return_filenames=False): diff --git a/sdks/python/apache_beam/io/filesystem.py b/sdks/python/apache_beam/io/filesystem.py index 92d55929309f..c854e5879722 100644 --- a/sdks/python/apache_beam/io/filesystem.py +++ b/sdks/python/apache_beam/io/filesystem.py @@ -257,8 +257,7 @@ def _read_from_internal_buffer(self, read_fn): self._read_buffer.seek(0, os.SEEK_END) # Allow future writes. return result - def read(self, num_bytes): - # type: (int) -> bytes + def read(self, num_bytes: Optional[int] = None) -> bytes: if not self._decompressor: raise ValueError('decompressor not initialized') diff --git a/sdks/python/apache_beam/testing/load_tests/load_test_metrics_utils.py b/sdks/python/apache_beam/testing/load_tests/load_test_metrics_utils.py index 7b975bbe8feb..010ff688e611 100644 --- a/sdks/python/apache_beam/testing/load_tests/load_test_metrics_utils.py +++ b/sdks/python/apache_beam/testing/load_tests/load_test_metrics_utils.py @@ -216,7 +216,7 @@ def __init__( 'InfluxDB') self.filters = filters - def publish_metrics(self, result, extra_metrics: dict): + def publish_metrics(self, result, extra_metrics: Optional[dict] = None): metric_id = uuid.uuid4().hex metrics = result.metrics().query(self.filters) @@ -232,7 +232,7 @@ def publish_metrics(self, result, extra_metrics: dict): for publisher in self.publishers: publisher.publish(insert_dicts) - def _prepare_extra_metrics(self, extra_metrics: dict, metric_id: str): + def _prepare_extra_metrics(self, extra_metrics: Optional[dict], metric_id: str): ts = time.time() return [ Metric(ts, metric_id, v, label=k).as_dict() for k, From 37acd46dc9077be4b95201cb2b562a75400e6a9f Mon Sep 17 00:00:00 2001 From: Miguel Hernandez Date: Wed, 2 Mar 2022 14:41:52 -0600 Subject: [PATCH 3/3] [BEAM-13051] Fixed parameters warnings --- .../testing/load_tests/load_test_metrics_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sdks/python/apache_beam/testing/load_tests/load_test_metrics_utils.py b/sdks/python/apache_beam/testing/load_tests/load_test_metrics_utils.py index 010ff688e611..0099d462af98 100644 --- a/sdks/python/apache_beam/testing/load_tests/load_test_metrics_utils.py +++ b/sdks/python/apache_beam/testing/load_tests/load_test_metrics_utils.py @@ -227,13 +227,16 @@ def publish_metrics(self, result, extra_metrics: Optional[dict] = None): # a list of dictionaries matching the schema. insert_dicts = self._prepare_all_metrics(metrics, metric_id) - insert_dicts += self._prepare_extra_metrics(extra_metrics, metric_id) + insert_dicts += self._prepare_extra_metrics(metric_id, extra_metrics) if len(insert_dicts) > 0: for publisher in self.publishers: publisher.publish(insert_dicts) - def _prepare_extra_metrics(self, extra_metrics: Optional[dict], metric_id: str): + def _prepare_extra_metrics( + self, metric_id: str, extra_metrics: Optional[dict] = None): ts = time.time() + if not extra_metrics: + extra_metrics = {} return [ Metric(ts, metric_id, v, label=k).as_dict() for k, v in extra_metrics.items()