From 9a160b4a4bf97f4f33c815114737959dd0f44857 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Mar 2021 12:06:16 +0000 Subject: [PATCH 1/4] Bump pylint from 2.6.0 to 2.7.2 Bumps [pylint](https://github.com/PyCQA/pylint) from 2.6.0 to 2.7.2. - [Release notes](https://github.com/PyCQA/pylint/releases) - [Changelog](https://github.com/PyCQA/pylint/blob/master/ChangeLog) - [Commits](https://github.com/PyCQA/pylint/compare/pylint-2.6.0...pylint-2.7.2) Signed-off-by: dependabot[bot] --- requirements/lint.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/requirements/lint.txt b/requirements/lint.txt index c20e6d58..d76fba08 100644 --- a/requirements/lint.txt +++ b/requirements/lint.txt @@ -13,7 +13,7 @@ amqp==5.0.2 # -r requirements/requirements.txt # -r requirements/tests.txt # kombu -astroid==2.4.2 +astroid==2.5.1 # via pylint attrs==20.3.0 # via @@ -232,7 +232,7 @@ pycparser==2.20 # cffi pydocstyle==5.1.1 # via -r requirements/lint.in -pylint==2.6.0 +pylint==2.7.2 # via -r requirements/lint.in pyparsing==2.4.7 # via @@ -314,7 +314,6 @@ six==1.15.0 # via # -r requirements/requirements.txt # -r requirements/tests.txt - # astroid # click-repl # cryptography # google-auth From bd0bec897a9cad070b5d892304fd4e5710a21a08 Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Tue, 16 Mar 2021 13:16:44 +0100 Subject: [PATCH 2/4] Remove useless pylint suppressions --- checkmate/db.py | 4 ++-- checkmate/migrations/env.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/checkmate/db.py b/checkmate/db.py index 3bcbc26b..b2bdbf2f 100644 --- a/checkmate/db.py +++ b/checkmate/db.py @@ -115,11 +115,11 @@ def _session(request): # pragma: no cover @request.add_finished_callback def close_the_sqlalchemy_session(_request): # pylint: disable=unused-variable connections = ( - session.transaction._connections # pylint:disable=protected-access,no-member + session.transaction._connections # pylint:disable=protected-access ) if len(connections) > 1: LOG.warning("closing an unclosed DB session") - session.close() # pylint:disable=no-member + session.close() return session diff --git a/checkmate/migrations/env.py b/checkmate/migrations/env.py index 67134697..e5eaf6b8 100644 --- a/checkmate/migrations/env.py +++ b/checkmate/migrations/env.py @@ -1,5 +1,5 @@ # We didn't write this, so we don't care -# pylint: disable=fixme,no-member +# pylint: disable=no-member import os from logging.config import fileConfig From 72b15344ccfcba5963bc4473454cdd0a06cf8558 Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Tue, 16 Mar 2021 13:17:01 +0100 Subject: [PATCH 3/4] Deduplicate sqlalchmy naming conventions --- checkmate/db.py | 18 +++++++++--------- checkmate/migrations/env.py | 13 +++---------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/checkmate/db.py b/checkmate/db.py index b2bdbf2f..09b5113d 100644 --- a/checkmate/db.py +++ b/checkmate/db.py @@ -11,6 +11,14 @@ LOG = logging.getLogger(__name__) +NAMING_CONVENTIONS = { + "ix": "ix__%(column_0_label)s", + "uq": "uq__%(table_name)s__%(column_0_name)s", + "ck": "ck__%(table_name)s__%(constraint_name)s", + "fk": "fk__%(table_name)s__%(column_0_name)s__%(referred_table_name)s", + "pk": "pk__%(table_name)s", +} + class BaseClass: """Functions common to all SQLAlchemy models.""" @@ -32,15 +40,7 @@ def __repr__(self): # alembic after creation much easier. See: # http://docs.sqlalchemy.org/en/latest/core/constraints.html#configuring-constraint-naming-conventions cls=BaseClass, - metadata=sqlalchemy.MetaData( - naming_convention={ - "ix": "ix__%(column_0_label)s", - "uq": "uq__%(table_name)s__%(column_0_name)s", - "ck": "ck__%(table_name)s__%(constraint_name)s", - "fk": "fk__%(table_name)s__%(column_0_name)s__%(referred_table_name)s", - "pk": "pk__%(table_name)s", - } - ), + metadata=sqlalchemy.MetaData(naming_convention=NAMING_CONVENTIONS), ) diff --git a/checkmate/migrations/env.py b/checkmate/migrations/env.py index e5eaf6b8..1892f594 100644 --- a/checkmate/migrations/env.py +++ b/checkmate/migrations/env.py @@ -7,6 +7,8 @@ from alembic import context from sqlalchemy import MetaData, engine_from_config, pool +from checkmate.db import NAMING_CONVENTIONS + # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config @@ -19,16 +21,7 @@ # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata -# FIXME: This duplicates the naming_convention in checkmate/db.py. -target_metadata = MetaData( - naming_convention={ - "ix": "ix__%(column_0_label)s", - "uq": "uq__%(table_name)s__%(column_0_name)s", - "ck": "ck__%(table_name)s__%(constraint_name)s", - "fk": "fk__%(table_name)s__%(column_0_name)s__%(referred_table_name)s", - "pk": "pk__%(table_name)s", - } -) +target_metadata = MetaData(naming_convention=NAMING_CONVENTIONS) # other values from the config, defined by the needs of env.py, # can be acquired: # my_important_option = config.get_main_option("my_important_option") From 0b085b41e629e8744222e81dcf78000686136a49 Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Tue, 16 Mar 2021 13:26:37 +0100 Subject: [PATCH 4/4] Adjust pylint similarities config --- tests/.pylintrc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/.pylintrc b/tests/.pylintrc index caf186b3..f85ba0fd 100644 --- a/tests/.pylintrc +++ b/tests/.pylintrc @@ -27,3 +27,16 @@ disable=bad-continuation, [REPORTS] output-format=colorized score=no + +[SIMILARITIES] +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=yes