diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5e8dc43..43e9f17 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ on: [push, pull_request] jobs: run-tox: # The type of runner that the job will run on - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -20,7 +20,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: 3.6.15 - name: Install Tox run: pip install tox - name: Upgrade setuptools diff --git a/.gitignore b/.gitignore index 2be14f0..279c72e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ __pycache__/* .*.swp */.ipynb_checkpoints/* .DS_Store +.tags # Project files .ropeproject @@ -48,3 +49,4 @@ MANIFEST # Per-project virtualenvs .venv*/ +.python-version diff --git a/docs/conf.py b/docs/conf.py index 1ba44b3..d40e17b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -91,8 +91,8 @@ master_doc = "index" # General information about the project. -project = u"eiffel-graphql-api" -copyright = u"2019, Axis Communications AB" +project = "eiffel-graphql-api" +copyright = "2019, Axis Communications AB" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -240,7 +240,7 @@ # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ("index", "user_guide.tex", u"Eiffel-graphql Documentation", u"", "manual"), + ("index", "user_guide.tex", "Eiffel-graphql Documentation", "", "manual"), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/docs/requirements.txt b/docs/requirements.txt index 1b50734..fa26b14 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,5 @@ sphinx<2 pyscaffold==2.5.10 +mistune==0.8.4 m2r==0.2.1 sphinx-rtd-theme<0.5 diff --git a/src/eiffel_graphql_api/graphql/schemas/lib/generic.py b/src/eiffel_graphql_api/graphql/schemas/lib/generic.py index f28b51f..e8e18a6 100644 --- a/src/eiffel_graphql_api/graphql/schemas/lib/generic.py +++ b/src/eiffel_graphql_api/graphql/schemas/lib/generic.py @@ -52,7 +52,7 @@ def load(name): :return: Json dictionary, starting from the properties key. :rtype: dict """ - with open(os.path.join(BASE_JSON, name)) as json_file: + with open(os.path.join(BASE_JSON, name), encoding="utf-8") as json_file: data = json.load(json_file) return data.get("properties") @@ -204,7 +204,7 @@ def key_names(key, override_name): # to change. By capitalizing just the first index and then attaching the rest # we achieve that. # Converts 'dataKey' to 'DataKey'. - cls_name = "{}{}".format(key[0].capitalize(), key[1:]) + cls_name = f"{key[0].capitalize()}{key[1:]}" attribute_name = convert(key) return key, data_key, cls_name, attribute_name @@ -236,7 +236,7 @@ def generate_array(key, value, override_name, data_dict): json_schema_to_graphql(cls_name, value, dictionary, override_name) obj = create_object_type(cls_name, dictionary, key) data_dict[attribute_name] = graphene.List(obj) - data_dict["resolve_{}".format(attribute_name)] = resolvers(graphene.List, data_key) + data_dict[f"resolve_{attribute_name}"] = resolvers(graphene.List, data_key) def generate_object(key, value, override_name, data_dict): @@ -265,7 +265,7 @@ def generate_object(key, value, override_name, data_dict): json_schema_to_graphql(cls_name, value.get("properties"), dictionary, override_name) obj = create_object_type(cls_name, dictionary) data_dict[attribute_name] = graphene.Field(obj) - data_dict["resolve_{}".format(attribute_name)] = resolvers(graphene.Field, data_key) + data_dict[f"resolve_{attribute_name}"] = resolvers(graphene.Field, data_key) def generate_simple(key, graphene_type, override_name, data_dict): @@ -287,7 +287,7 @@ def generate_simple(key, graphene_type, override_name, data_dict): """ key, _, __, attribute_name = key_names(key, override_name) data_dict[attribute_name] = graphene_type() - data_dict["resolve_{}".format(attribute_name)] = resolvers(graphene_type, key) + data_dict[f"resolve_{attribute_name}"] = resolvers(graphene_type, key) def json_schema_to_graphql( diff --git a/src/eiffel_graphql_api/graphql/schemas/schema.py b/src/eiffel_graphql_api/graphql/schemas/schema.py index d36a8bd..99a05d8 100644 --- a/src/eiffel_graphql_api/graphql/schemas/schema.py +++ b/src/eiffel_graphql_api/graphql/schemas/schema.py @@ -29,7 +29,7 @@ class EiffelConnectionField(relay.ConnectionField): def __init__(self, field): """Initialize schema fields.""" - field = "eiffel_graphql_api.graphql.schemas.events.{}".format(field) + field = f"eiffel_graphql_api.graphql.schemas.events.{field}" # pylint:disable=super-with-arguments super(EiffelConnectionField, self).__init__(field, search=graphene.String()) @@ -58,7 +58,7 @@ def generic_resolve( """Generically resolve a meta node for each eiffel object type.""" # pylint:disable=protected-access obj = info.return_type.graphene_type._meta.node - collection = "Eiffel{}Event".format(obj) + collection = f"Eiffel{obj}Event" search = "{}" if search is None else search search = cls._clean_query(search) @@ -82,8 +82,8 @@ def generic_resolve( NAME = NAME.replace("Eiffel", "") NAME = NAME.replace("Event", "") NAME = NAME.replace(".json", "") - CONNECTION_NAME = "{}Connection".format(NAME) - RESOLVE_NAME = "resolve_{}".format(convert(NAME)) + CONNECTION_NAME = f"{NAME}Connection" + RESOLVE_NAME = f"resolve_{convert(NAME)}" SNAKE_NAME = convert(NAME) QUERY[SNAKE_NAME] = EiffelConnectionField(CONNECTION_NAME) QUERY[RESOLVE_NAME] = BaseQuery.generic_resolve diff --git a/src/eiffel_graphql_api/storage.py b/src/eiffel_graphql_api/storage.py index 182bf0c..9aa393f 100644 --- a/src/eiffel_graphql_api/storage.py +++ b/src/eiffel_graphql_api/storage.py @@ -31,10 +31,10 @@ # Set environment variables from rabbitmq secrets in a kubernetes cluster. if os.path.isfile("/etc/rabbitmq/password"): - with open("/etc/rabbitmq/password", "r") as password: + with open("/etc/rabbitmq/password", "r", encoding="utf-8") as password: os.environ["RABBITMQ_PASSWORD"] = password.read() if os.path.isfile("/etc/rabbitmq/username"): - with open("/etc/rabbitmq/username", "r") as username: + with open("/etc/rabbitmq/username", "r", encoding="utf-8") as username: os.environ["RABBITMQ_USERNAME"] = username.read() @@ -52,7 +52,7 @@ def parse_args(args): parser.add_argument( "--version", action="version", - version="eiffel-graphql-storage {ver}".format(ver=__version__), + version=f"eiffel-graphql-storage {__version__}", ) parser.add_argument( "-v", diff --git a/tests/test_events/activity_finished/test_activity_finished.py b/tests/test_events/activity_finished/test_activity_finished.py index 098dc76..19cc943 100644 --- a/tests/test_events/activity_finished/test_activity_finished.py +++ b/tests/test_events/activity_finished/test_activity_finished.py @@ -110,10 +110,9 @@ def test_activity_finished_persistent_logs(self): self.assertEqual(log.get("uri"), uri) break else: + logs = data.get("activityPersistentLogs") raise AssertionError( - "{{'name': {}, 'uri': {}}} not in liveLogs: {}".format( - name, uri, data.get("activityPersistentLogs") - ) + f"{{'name': {name}, 'uri': {uri}}} not in liveLogs: {logs}" ) def test_activity_finished_link(self): diff --git a/tox.ini b/tox.ini index a8051a6..ef0dc28 100644 --- a/tox.ini +++ b/tox.ini @@ -8,9 +8,9 @@ envlist = py36,black,docs,pylint,pydocstyle [testenv] deps = - pytest - pytest-cov - mongomock + pytest==7.0 + pytest-cov==4.0.0 + mongomock==4.1.2 setenv = MONGODB_CONNSTRING = mongodb://localhost:27017 MONGODB_DATABASE = testing_eiffel_graphql_api commands = @@ -19,27 +19,27 @@ basepython = python3.6 [testenv:black] deps = - black + black==22.8.0 commands = black --check --diff . [testenv:docs] deps = - -r docs/requirements.txt + -r docs/requirements.txt commands = python setup.py docs [testenv:pylint] deps = - pylint - pytest - pytest-cov - mongomock + pylint==2.12.2 + pytest==7.0 + pytest-cov==4.0.0 + mongomock==4.1.2 commands = pylint src/eiffel_graphql_api tests [testenv:pydocstyle] deps = - pydocstyle + pydocstyle==6.3.0 commands = pydocstyle .