Skip to content

Commit

Permalink
Merge pull request apache#16562 from [BEAM-13051][D] Enable pylint wa…
Browse files Browse the repository at this point in the history
…rnings (no-name-in-module/no-value-for-parameter)

* [BEAM-13051] Pylint no-name-in-module and no-value-for-parameter warnings enabled

* [BEAM-13051] Fixed no-value-for-parameter warning for missing default values

* [BEAM-13051] Fixed parameters warnings
  • Loading branch information
roger-mike authored and nancyxu123 committed Mar 9, 2022
1 parent 13a06f4 commit 402356d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 7 additions & 1 deletion sdks/python/apache_beam/io/avroio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions sdks/python/apache_beam/io/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -227,13 +227,16 @@ def publish_metrics(self, result, extra_metrics: dict):
# 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: 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()
Expand Down

0 comments on commit 402356d

Please sign in to comment.