Skip to content

Commit

Permalink
pylint: Fix newer pylint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ormod committed Apr 18, 2017
1 parent 522fe6f commit 497b54b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ disable=
duplicate-code,
fixme,
invalid-name,
len-as-condition,
locally-disabled,
missing-docstring,
no-else-return,
no-self-use,
too-few-public-methods,
too-many-ancestors,
Expand Down
3 changes: 1 addition & 2 deletions pghoard/pghoard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

"""
pghoard - main pghoard daemon
Expand Down Expand Up @@ -148,7 +147,7 @@ def check_pg_server_version(self, connection_string):
pg_version = None
try:
with closing(psycopg2.connect(connection_string)) as c:
pg_version = c.server_version
pg_version = c.server_version # pylint: disable=no-member
except psycopg2.OperationalError as ex:
self.log.warning("%s (%s) connecting to DB at: %r",
ex.__class__.__name__, ex, connection_string)
Expand Down
2 changes: 1 addition & 1 deletion pghoard/rohmu/object_storage/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def format_key_from_backend(self, key):
def delete_key(self, key):
raise NotImplementedError

def get_contents_to_file(self, key, path, *, progress_callback=None):
def get_contents_to_file(self, key, filepath_to_store_to, *, progress_callback=None):
"""Write key contents to file pointed by `path` and return metadata. If `progress_callback` is
provided it must be a function which accepts two numeric arguments: current state of progress and the
expected maximum value. The actual values and value ranges differ per storage provider, some (S3)
Expand Down
10 changes: 5 additions & 5 deletions pghoard/statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ def _send(self, metric, metric_type, value, tags):
send_tags = self._tags.copy()
send_tags.update(tags or {})
if self._message_format == "datadog":
for index, (tag, value) in enumerate(send_tags.items()):
for index, (tag, val) in enumerate(send_tags.items()):
if index == 0:
separator = "|#"
else:
separator = ","
if value is None:
if val is None:
pattern = "{}{}"
else:
pattern = "{}{}:{}"
parts.append(pattern.format(separator, tag, value).encode("utf-8"))
parts.append(pattern.format(separator, tag, val).encode("utf-8"))
else:
for tag, value in send_tags.items():
parts.insert(1, ",{}={}".format(tag, value).encode("utf-8"))
for tag, val in send_tags.items():
parts.insert(1, ",{}={}".format(tag, val).encode("utf-8"))

self._socket.sendto(b"".join(parts), self._dest_addr)
2 changes: 1 addition & 1 deletion pghoard/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def transmit_statsd_metrics(self):
Transmits max once per ten seconds, regardless of how many threads are running.
"""
global _last_stats_transmit_time # pylint: disable=global-statement
with _STATS_LOCK:
with _STATS_LOCK: # pylint: disable=not-context-manager
if time.time() - _last_stats_transmit_time < 10.0:
return

Expand Down
4 changes: 2 additions & 2 deletions pghoard/wal.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def verify_wal(*, wal_name, fileobj=None, filepath=None):
source_name = getattr(fileobj, "name", "<UNKNOWN>")
else:
source_name = filepath
with open(filepath, "rb") as fileobj:
header_bytes = fileobj.read(WAL_HEADER_LEN)
with open(filepath, "rb") as fileobject:
header_bytes = fileobject.read(WAL_HEADER_LEN)

hdr = read_header(header_bytes)
except (KeyError, OSError, ValueError) as ex:
Expand Down

0 comments on commit 497b54b

Please sign in to comment.