diff --git a/.pylintrc b/.pylintrc index 11004cecb9a805b45f346db13569c2590a1c65f3..49fc90121a975941cd67b08cab0a9ea51f4a0883 100644 --- a/.pylintrc +++ b/.pylintrc @@ -60,17 +60,7 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use "--disable=all --enable=classes # --disable=W". -disable=print-statement, - parameter-unpacking, - unpacking-in-except, - old-raise-syntax, - backtick, - long-suffix, - old-ne-operator, - old-octal-literal, - import-star-module-level, - non-ascii-bytes-literal, - raw-checker-failed, +disable=raw-checker-failed, bad-inline-option, locally-disabled, file-ignored, @@ -78,67 +68,6 @@ disable=print-statement, useless-suppression, deprecated-pragma, use-symbolic-message-instead, - apply-builtin, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - execfile-builtin, - file-builtin, - long-builtin, - raw_input-builtin, - reduce-builtin, - standarderror-builtin, - unicode-builtin, - xrange-builtin, - coerce-method, - delslice-method, - getslice-method, - setslice-method, - no-absolute-import, - old-division, - dict-iter-method, - dict-view-method, - next-method-called, - metaclass-assignment, - indexing-exception, - raising-string, - reload-builtin, - oct-method, - hex-method, - nonzero-method, - cmp-method, - input-builtin, - round-builtin, - intern-builtin, - unichr-builtin, - map-builtin-not-iterating, - zip-builtin-not-iterating, - range-builtin-not-iterating, - filter-builtin-not-iterating, - using-cmp-argument, - eq-without-hash, - div-method, - idiv-method, - rdiv-method, - exception-message-attribute, - invalid-str-codec, - sys-max-int, - bad-python3-import, - deprecated-string-function, - deprecated-str-translate-call, - deprecated-itertools-function, - deprecated-types-field, - next-method-defined, - dict-items-not-iterating, - dict-keys-not-iterating, - dict-values-not-iterating, - deprecated-operator-function, - deprecated-urllib-function, - xreadlines-attribute, - deprecated-sys-function, - exception-escape, - comprehension-escape, missing-docstring, import-error, broad-except, @@ -266,13 +195,6 @@ max-line-length=100 # Maximum number of lines in a module. max-module-lines=1000 -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no diff --git a/postfix_mta_sts_resolver/daemon.py b/postfix_mta_sts_resolver/daemon.py index f079f255184895350c7efbe33b81b031cbc44bc0..db3436864e3a0bb95c2170f114efc844ed7c103c 100644 --- a/postfix_mta_sts_resolver/daemon.py +++ b/postfix_mta_sts_resolver/daemon.py @@ -107,21 +107,21 @@ async def amain(cfg, loop): # pragma: no cover def main(): # pragma: no cover args = parse_args() if args.pidfile is not None: - with open(args.pidfile, 'w') as f: - f.write(str(os.getpid())) + with open(args.pidfile, 'w', encoding='ascii') as pid_file: + pid_file.write(str(os.getpid())) if args.group is not None: try: - g = grp.getgrnam(args.group) - os.setegid(g.gr_gid) - except Exception as e: - print("Unable to change eGID to '{}': {}".format(args.group, e), file=sys.stderr) + group = grp.getgrnam(args.group) + os.setegid(group.gr_gid) + except Exception as exc: + print("Unable to change eGID to '{}': {}".format(args.group, exc), file=sys.stderr) return os.EX_OSERR if args.user is not None: try: - p = pwd.getpwnam(args.user) - os.seteuid(p.pw_uid) - except Exception as e: - print("Unable to change eUID to '{}': {}".format(args.user, e), file=sys.stderr) + passwd = pwd.getpwnam(args.user) + os.seteuid(passwd.pw_uid) + except Exception as exc: + print("Unable to change eUID to '{}': {}".format(args.user, exc), file=sys.stderr) return os.EX_OSERR with utils.AsyncLoggingHandler(args.logfile) as log_handler: logger = utils.setup_logger('MAIN', args.verbosity, log_handler) @@ -148,3 +148,4 @@ def main(): # pragma: no cover evloop.run_until_complete(amain(cfg, evloop)) evloop.close() logger.info("Server finished its work.") + return os.EX_OK diff --git a/postfix_mta_sts_resolver/postgres_cache.py b/postfix_mta_sts_resolver/postgres_cache.py index c70b9d7f18d3520725dae21f8856d427ec178c7f..f4ac4ed0248d5cb33358cf708393dfc21d296c9c 100644 --- a/postfix_mta_sts_resolver/postgres_cache.py +++ b/postfix_mta_sts_resolver/postgres_cache.py @@ -1,10 +1,10 @@ # pylint: disable=invalid-name,protected-access -import asyncio -import asyncpg import json import logging +import asyncpg + from .defaults import POSTGRES_TIMEOUT from .base_cache import BaseCache, CacheEntry