Skip to content

Make sure this still works with python 3.6 #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ __pycache__/*
.*.swp
*/.ipynb_checkpoints/*
.DS_Store
.tags

# Project files
.ropeproject
Expand Down Expand Up @@ -48,3 +49,4 @@ MANIFEST

# Per-project virtualenvs
.venv*/
.python-version
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sphinx<2
pyscaffold==2.5.10
mistune==0.8.4
m2r==0.2.1
sphinx-rtd-theme<0.5
10 changes: 5 additions & 5 deletions src/eiffel_graphql_api/graphql/schemas/lib/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions src/eiffel_graphql_api/graphql/schemas/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/eiffel_graphql_api/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
20 changes: 10 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 .