diff --git a/poetry.lock b/poetry.lock index feabcf5..1a2ea24 100644 --- a/poetry.lock +++ b/poetry.lock @@ -38,10 +38,10 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [package.extras] -dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"] -docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"] -tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"] -tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"] +tests_no_zope = ["cloudpickle", "pytest-mypy-plugins", "mypy", "six", "pytest (>=4.3.0)", "pympler", "hypothesis", "coverage[toml] (>=5.0.2)"] +tests = ["cloudpickle", "zope.interface", "pytest-mypy-plugins", "mypy", "six", "pytest (>=4.3.0)", "pympler", "hypothesis", "coverage[toml] (>=5.0.2)"] +docs = ["sphinx-notfound-page", "zope.interface", "sphinx", "furo"] +dev = ["cloudpickle", "pre-commit", "sphinx-notfound-page", "sphinx", "furo", "zope.interface", "pytest-mypy-plugins", "mypy", "six", "pytest (>=4.3.0)", "pympler", "hypothesis", "coverage[toml] (>=5.0.2)"] [[package]] name = "bandit" @@ -58,9 +58,9 @@ PyYAML = ">=5.3.1" stevedore = ">=1.20.0" [package.extras] -test = ["coverage (>=4.5.4)", "fixtures (>=3.0.0)", "flake8 (>=4.0.0)", "stestr (>=2.5.0)", "testscenarios (>=0.5.0)", "testtools (>=2.3.0)", "toml", "beautifulsoup4 (>=4.8.0)", "pylint (==1.9.4)"] -toml = ["toml"] yaml = ["pyyaml"] +toml = ["toml"] +test = ["pylint (==1.9.4)", "beautifulsoup4 (>=4.8.0)", "toml", "testtools (>=2.3.0)", "testscenarios (>=0.5.0)", "stestr (>=2.5.0)", "flake8 (>=4.0.0)", "fixtures (>=3.0.0)", "coverage (>=4.5.4)"] [[package]] name = "certifi" @@ -179,7 +179,7 @@ pydocstyle = ">=2.1" [[package]] name = "flake8-eradicate" -version = "1.2.1" +version = "1.3.0" description = "Flake8 plugin to find commented out code" category = "dev" optional = false @@ -188,7 +188,7 @@ python-versions = ">=3.6,<4.0" [package.dependencies] attrs = "*" eradicate = ">=2.0,<3.0" -flake8 = ">=3.5,<5" +flake8 = ">=3.5,<6" [[package]] name = "flake8-isort" @@ -207,12 +207,16 @@ test = ["pytest-cov"] [[package]] name = "flake8-logging-format" -version = "0.6.0" -description = "Flake8 extension to validate (lack of) logging format strings" +version = "0.7.5" +description = "" category = "dev" optional = false python-versions = "*" +[package.extras] +lint = ["flake8"] +test = ["pytest", "pytest-cov", "pyhamcrest"] + [[package]] name = "flake8-pep3101" version = "1.3.0" @@ -293,8 +297,8 @@ typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} zipp = ">=0.5" [package.extras] -docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] -testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] +testing = ["importlib-resources (>=1.3)", "pytest-mypy", "pytest-black (>=0.3.7)", "flufl.flake8", "pyfakefs", "pep517", "packaging", "pytest-enabler (>=1.0.1)", "pytest-cov", "pytest-flake8", "pytest-checkdocs (>=2.4)", "pytest (>=4.6)"] +docs = ["rst.linker (>=1.9)", "jaraco.packaging (>=8.2)", "sphinx"] [[package]] name = "importlib-resources" @@ -328,10 +332,10 @@ optional = false python-versions = ">=3.6.1,<4.0" [package.extras] -pipfile_deprecated_finder = ["pipreqs", "requirementslib"] -requirements_deprecated_finder = ["pipreqs", "pip-api"] -colors = ["colorama (>=0.4.3,<0.5.0)"] plugins = ["setuptools"] +colors = ["colorama (>=0.4.3,<0.5.0)"] +requirements_deprecated_finder = ["pip-api", "pipreqs"] +pipfile_deprecated_finder = ["requirementslib", "pipreqs"] [[package]] name = "jsonschema" @@ -410,11 +414,11 @@ python-versions = ">=2.6" [[package]] name = "pep8-naming" -version = "0.13.1" +version = "0.13.2" description = "Check PEP-8 naming conventions, plugin for flake8" category = "dev" optional = false -python-versions = "*" +python-versions = ">=3.7" [package.dependencies] flake8 = ">=3.9.1" @@ -508,7 +512,7 @@ optional = false python-versions = ">=3.6.8" [package.extras] -diagrams = ["railroad-diagrams", "jinja2"] +diagrams = ["jinja2", "railroad-diagrams"] [[package]] name = "pyrsistent" @@ -538,7 +542,7 @@ py = ">=1.8.2" tomli = ">=1.0.0" [package.extras] -testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] +testing = ["xmlschema", "requests", "pygments (>=2.7.2)", "nose", "mock", "hypothesis (>=3.56)", "argcomplete"] [[package]] name = "pytest-cov" @@ -611,8 +615,8 @@ idna = ">=2.5,<4" urllib3 = ">=1.21.1,<1.27" [package.extras] -socks = ["PySocks (>=1.5.6,!=1.5.7)"] use_chardet_on_py3 = ["chardet (>=3.0.2,<6)"] +socks = ["PySocks (>=1.5.6,!=1.5.7)"] [[package]] name = "ruamel.yaml" @@ -706,9 +710,9 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" [package.extras] -brotli = ["brotlicffi (>=0.8.0)", "brotli (>=1.0.9)", "brotlipy (>=0.6.0)"] -secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] +secure = ["ipaddress", "certifi", "idna (>=2.0.0)", "cryptography (>=1.3.4)", "pyOpenSSL (>=0.14)"] +brotli = ["brotlipy (>=0.6.0)", "brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] [[package]] name = "yapf" @@ -727,13 +731,13 @@ optional = false python-versions = ">=3.7" [package.extras] -docs = ["sphinx", "jaraco.packaging (>=9)", "rst.linker (>=1.9)"] -testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)"] +testing = ["pytest-mypy (>=0.9.1)", "pytest-black (>=0.3.7)", "func-timeout", "jaraco.itertools", "pytest-enabler (>=1.0.1)", "pytest-cov", "pytest-flake8", "pytest-checkdocs (>=2.4)", "pytest (>=6)"] +docs = ["rst.linker (>=1.9)", "jaraco.packaging (>=9)", "sphinx"] [metadata] lock-version = "1.1" python-versions = "^3.7.0" -content-hash = "18c3930e5cb231cc8e43980c6c8c2a00ed07c331829d3b0d6269dc84a0613da5" +content-hash = "09dff6c8ee885159170a09d290bbc8d8d2e907a774e97f32b7833b98e373a227" [metadata.files] anyconfig = [ @@ -844,15 +848,15 @@ flake8-docstrings = [ {file = "flake8_docstrings-1.6.0-py2.py3-none-any.whl", hash = "sha256:99cac583d6c7e32dd28bbfbef120a7c0d1b6dde4adb5a9fd441c4227a6534bde"}, ] flake8-eradicate = [ - {file = "flake8-eradicate-1.2.1.tar.gz", hash = "sha256:e486f8ab7e2dba3667223688e9239158fbf4ecaa88125e2283bcda81171412b7"}, - {file = "flake8_eradicate-1.2.1-py3-none-any.whl", hash = "sha256:00d77faefb64cef18b3c1b48a004c3a2ad663aa3cf85650f422437d25ece6441"}, + {file = "flake8-eradicate-1.3.0.tar.gz", hash = "sha256:e4c98f00d17dc8653e3388cac2624cd81e9735de2fd4a8dcf99029633ebd7a63"}, + {file = "flake8_eradicate-1.3.0-py3-none-any.whl", hash = "sha256:85a71e0c5f4e07f7c6c5fec520483561fd6bd295417d622855bdeade99242e3d"}, ] flake8-isort = [ {file = "flake8-isort-4.2.0.tar.gz", hash = "sha256:26571500cd54976bbc0cf1006ffbcd1a68dd102f816b7a1051b219616ba9fee0"}, {file = "flake8_isort-4.2.0-py3-none-any.whl", hash = "sha256:5b87630fb3719bf4c1833fd11e0d9534f43efdeba524863e15d8f14a7ef6adbf"}, ] flake8-logging-format = [ - {file = "flake8-logging-format-0.6.0.tar.gz", hash = "sha256:ca5f2b7fc31c3474a0aa77d227e022890f641a025f0ba664418797d979a779f8"}, + {file = "flake8-logging-format-0.7.5.tar.gz", hash = "sha256:54f7e349c934ce5c594f251885bc2240e99f6b48752a672a8fc7e3d1388352bb"}, ] flake8-pep3101 = [ {file = "flake8-pep3101-1.3.0.tar.gz", hash = "sha256:86e3eb4e42de8326dcd98ebdeaf9a3c6854203a48f34aeb3e7e8ed948107f512"}, @@ -917,8 +921,8 @@ pbr = [ {file = "pbr-5.9.0.tar.gz", hash = "sha256:e8dca2f4b43560edef58813969f52a56cef023146cbb8931626db80e6c1c4308"}, ] pep8-naming = [ - {file = "pep8-naming-0.13.1.tar.gz", hash = "sha256:3af77cdaa9c7965f7c85a56cd579354553c9bbd3fdf3078a776f12db54dd6944"}, - {file = "pep8_naming-0.13.1-py3-none-any.whl", hash = "sha256:f7867c1a464fe769be4f972ef7b79d6df1d9aff1b1f04ecf738d471963d3ab9c"}, + {file = "pep8-naming-0.13.2.tar.gz", hash = "sha256:93eef62f525fd12a6f8c98f4dcc17fa70baae2f37fa1f73bec00e3e44392fa48"}, + {file = "pep8_naming-0.13.2-py3-none-any.whl", hash = "sha256:59e29e55c478db69cffbe14ab24b5bd2cd615c0413edf790d47d3fb7ba9a4e23"}, ] pkgutil-resolve-name = [ {file = "pkgutil_resolve_name-1.3.10-py3-none-any.whl", hash = "sha256:ca27cc078d25c5ad71a9de0a7a330146c4e014c2462d9af19c6b828280649c5e"}, diff --git a/prometheuspvesd/logger.py b/prometheuspvesd/logger.py index 1411d89..2c90e4f 100644 --- a/prometheuspvesd/logger.py +++ b/prometheuspvesd/logger.py @@ -70,11 +70,11 @@ class MultilineJsonFormatter(jsonlogger.JsonFormatter): class Log: """Handle logging.""" - def __init__(self, level=logging.WARN, name="prometheuspvesd", log_format="console"): + def __init__(self, level=logging.WARNING, name="prometheuspvesd", log_format="console"): self.logger = logging.getLogger(name) self.logger.setLevel(level) self.logger.addHandler(self._get_error_handler(log_format)) - self.logger.addHandler(self._get_warn_handler(log_format)) + self.logger.addHandler(self._get_warning_handler(log_format)) self.logger.addHandler(self._get_info_handler(log_format)) self.logger.addHandler(self._get_critical_handler(log_format)) self.logger.addHandler(self._get_debug_handler(log_format)) @@ -102,10 +102,10 @@ class Log: return handler - def _get_warn_handler(self, log_format): + def _get_warning_handler(self, log_format): handler = logging.StreamHandler(sys.stdout) - handler.setLevel(logging.WARN) - handler.addFilter(LogFilter(logging.WARN)) + handler.setLevel(logging.WARNING) + handler.addFilter(LogFilter(logging.WARNING)) if log_format == "json": handler.setFormatter(MultilineJsonFormatter(JSON_FORMAT)) @@ -114,7 +114,7 @@ class Log: else: handler.setFormatter( MultilineFormatter( - self.warn( + self.warning( CONSOLE_FORMAT.format( colorama.Fore.YELLOW, colorama.Style.BRIGHT, colorama.Style.RESET_ALL ) @@ -196,7 +196,7 @@ class Log: self.logger.setLevel(level) self.logger.addHandler(self._get_error_handler(log_level)) - self.logger.addHandler(self._get_warn_handler(log_level)) + self.logger.addHandler(self._get_warning_handler(log_level)) self.logger.addHandler(self._get_info_handler(log_level)) self.logger.addHandler(self._get_critical_handler(log_level)) self.logger.addHandler(self._get_debug_handler(log_level)) @@ -213,8 +213,8 @@ class Log: """Format error messages and return string.""" return msg - def warn(self, msg): - """Format warn messages and return string.""" + def warning(self, msg): + """Format warning messages and return string.""" return msg def info(self, msg): diff --git a/pyproject.toml b/pyproject.toml index 5dd12c4..72c7545 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,13 +48,13 @@ flake8 = "4.0.1" flake8-blind-except = "0.2.1" flake8-builtins = "1.5.3" flake8-docstrings = "1.6.0" -flake8-eradicate = "1.2.1" +flake8-eradicate = "1.3.0" flake8-isort = "4.2.0" -flake8-logging-format = "0.6.0" +flake8-logging-format = "0.7.5" flake8-pep3101 = "1.3.0" flake8-polyfill = "1.0.2" flake8-quotes = "3.3.1" -pep8-naming = "0.13.1" +pep8-naming = "0.13.2" pydocstyle = "6.1.1" pytest = "7.1.2" pytest-cov = "3.0.0" diff --git a/setup.cfg b/setup.cfg index fa0e667..bf0e15d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,8 +6,10 @@ # D105: Missing docstring in magic method # D107: Missing docstring in __init__ # D202: No blank lines allowed after function docstring -# W503:Line break occurred before a binary operator -ignore = D102, D103, D105, D107, D202, W503 +# G001: Logging statements should not use string.format() for their first argument +# G004: Logging statements should not use f"..." for their first argument +# W503: Line break occurred before a binary operator +ignore = D102, D103, D105, D107, D202, G001, G004, W503 max-line-length = 99 inline-quotes = double exclude = .git, __pycache__, build, dist, *.pyc, *.egg-info, .cache, .eggs, env*