Skip to content

Commit 23c4c91

Browse files
authored
Make sure this still works with python 3.6 (#69)
Pin versions for everything in tox.ini Pin mistune version to version 1 Fix pylint errors and run black
1 parent 19464c4 commit 23c4c91

File tree

9 files changed

+32
-30
lines changed

9 files changed

+32
-30
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on: [push, pull_request]
1010
jobs:
1111
run-tox:
1212
# The type of runner that the job will run on
13-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-20.04
1414

1515
# Steps represent a sequence of tasks that will be executed as part of the job
1616
steps:
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup python
2121
uses: actions/setup-python@v2
2222
with:
23-
python-version: 3.6
23+
python-version: 3.6.15
2424
- name: Install Tox
2525
run: pip install tox
2626
- name: Upgrade setuptools

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ __pycache__/*
1313
.*.swp
1414
*/.ipynb_checkpoints/*
1515
.DS_Store
16+
.tags
1617

1718
# Project files
1819
.ropeproject
@@ -48,3 +49,4 @@ MANIFEST
4849

4950
# Per-project virtualenvs
5051
.venv*/
52+
.python-version

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@
9191
master_doc = "index"
9292

9393
# General information about the project.
94-
project = u"eiffel-graphql-api"
95-
copyright = u"2019, Axis Communications AB"
94+
project = "eiffel-graphql-api"
95+
copyright = "2019, Axis Communications AB"
9696

9797
# The version info for the project you're documenting, acts as replacement for
9898
# |version| and |release|, also used in various other places throughout the
@@ -240,7 +240,7 @@
240240
# Grouping the document tree into LaTeX files. List of tuples
241241
# (source start file, target name, title, author, documentclass [howto/manual]).
242242
latex_documents = [
243-
("index", "user_guide.tex", u"Eiffel-graphql Documentation", u"", "manual"),
243+
("index", "user_guide.tex", "Eiffel-graphql Documentation", "", "manual"),
244244
]
245245

246246
# The name of an image file (relative to this directory) to place at the top of

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
sphinx<2
22
pyscaffold==2.5.10
3+
mistune==0.8.4
34
m2r==0.2.1
45
sphinx-rtd-theme<0.5

src/eiffel_graphql_api/graphql/schemas/lib/generic.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def load(name):
5252
:return: Json dictionary, starting from the properties key.
5353
:rtype: dict
5454
"""
55-
with open(os.path.join(BASE_JSON, name)) as json_file:
55+
with open(os.path.join(BASE_JSON, name), encoding="utf-8") as json_file:
5656
data = json.load(json_file)
5757
return data.get("properties")
5858

@@ -204,7 +204,7 @@ def key_names(key, override_name):
204204
# to change. By capitalizing just the first index and then attaching the rest
205205
# we achieve that.
206206
# Converts 'dataKey' to 'DataKey'.
207-
cls_name = "{}{}".format(key[0].capitalize(), key[1:])
207+
cls_name = f"{key[0].capitalize()}{key[1:]}"
208208
attribute_name = convert(key)
209209
return key, data_key, cls_name, attribute_name
210210

@@ -236,7 +236,7 @@ def generate_array(key, value, override_name, data_dict):
236236
json_schema_to_graphql(cls_name, value, dictionary, override_name)
237237
obj = create_object_type(cls_name, dictionary, key)
238238
data_dict[attribute_name] = graphene.List(obj)
239-
data_dict["resolve_{}".format(attribute_name)] = resolvers(graphene.List, data_key)
239+
data_dict[f"resolve_{attribute_name}"] = resolvers(graphene.List, data_key)
240240

241241

242242
def generate_object(key, value, override_name, data_dict):
@@ -265,7 +265,7 @@ def generate_object(key, value, override_name, data_dict):
265265
json_schema_to_graphql(cls_name, value.get("properties"), dictionary, override_name)
266266
obj = create_object_type(cls_name, dictionary)
267267
data_dict[attribute_name] = graphene.Field(obj)
268-
data_dict["resolve_{}".format(attribute_name)] = resolvers(graphene.Field, data_key)
268+
data_dict[f"resolve_{attribute_name}"] = resolvers(graphene.Field, data_key)
269269

270270

271271
def generate_simple(key, graphene_type, override_name, data_dict):
@@ -287,7 +287,7 @@ def generate_simple(key, graphene_type, override_name, data_dict):
287287
"""
288288
key, _, __, attribute_name = key_names(key, override_name)
289289
data_dict[attribute_name] = graphene_type()
290-
data_dict["resolve_{}".format(attribute_name)] = resolvers(graphene_type, key)
290+
data_dict[f"resolve_{attribute_name}"] = resolvers(graphene_type, key)
291291

292292

293293
def json_schema_to_graphql(

src/eiffel_graphql_api/graphql/schemas/schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class EiffelConnectionField(relay.ConnectionField):
2929

3030
def __init__(self, field):
3131
"""Initialize schema fields."""
32-
field = "eiffel_graphql_api.graphql.schemas.events.{}".format(field)
32+
field = f"eiffel_graphql_api.graphql.schemas.events.{field}"
3333
# pylint:disable=super-with-arguments
3434
super(EiffelConnectionField, self).__init__(field, search=graphene.String())
3535

@@ -58,7 +58,7 @@ def generic_resolve(
5858
"""Generically resolve a meta node for each eiffel object type."""
5959
# pylint:disable=protected-access
6060
obj = info.return_type.graphene_type._meta.node
61-
collection = "Eiffel{}Event".format(obj)
61+
collection = f"Eiffel{obj}Event"
6262

6363
search = "{}" if search is None else search
6464
search = cls._clean_query(search)
@@ -82,8 +82,8 @@ def generic_resolve(
8282
NAME = NAME.replace("Eiffel", "")
8383
NAME = NAME.replace("Event", "")
8484
NAME = NAME.replace(".json", "")
85-
CONNECTION_NAME = "{}Connection".format(NAME)
86-
RESOLVE_NAME = "resolve_{}".format(convert(NAME))
85+
CONNECTION_NAME = f"{NAME}Connection"
86+
RESOLVE_NAME = f"resolve_{convert(NAME)}"
8787
SNAKE_NAME = convert(NAME)
8888
QUERY[SNAKE_NAME] = EiffelConnectionField(CONNECTION_NAME)
8989
QUERY[RESOLVE_NAME] = BaseQuery.generic_resolve

src/eiffel_graphql_api/storage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131

3232
# Set environment variables from rabbitmq secrets in a kubernetes cluster.
3333
if os.path.isfile("/etc/rabbitmq/password"):
34-
with open("/etc/rabbitmq/password", "r") as password:
34+
with open("/etc/rabbitmq/password", "r", encoding="utf-8") as password:
3535
os.environ["RABBITMQ_PASSWORD"] = password.read()
3636
if os.path.isfile("/etc/rabbitmq/username"):
37-
with open("/etc/rabbitmq/username", "r") as username:
37+
with open("/etc/rabbitmq/username", "r", encoding="utf-8") as username:
3838
os.environ["RABBITMQ_USERNAME"] = username.read()
3939

4040

@@ -52,7 +52,7 @@ def parse_args(args):
5252
parser.add_argument(
5353
"--version",
5454
action="version",
55-
version="eiffel-graphql-storage {ver}".format(ver=__version__),
55+
version=f"eiffel-graphql-storage {__version__}",
5656
)
5757
parser.add_argument(
5858
"-v",

tests/test_events/activity_finished/test_activity_finished.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ def test_activity_finished_persistent_logs(self):
110110
self.assertEqual(log.get("uri"), uri)
111111
break
112112
else:
113+
logs = data.get("activityPersistentLogs")
113114
raise AssertionError(
114-
"{{'name': {}, 'uri': {}}} not in liveLogs: {}".format(
115-
name, uri, data.get("activityPersistentLogs")
116-
)
115+
f"{{'name': {name}, 'uri': {uri}}} not in liveLogs: {logs}"
117116
)
118117

119118
def test_activity_finished_link(self):

tox.ini

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ envlist = py36,black,docs,pylint,pydocstyle
88

99
[testenv]
1010
deps =
11-
pytest
12-
pytest-cov
13-
mongomock
11+
pytest==7.0
12+
pytest-cov==4.0.0
13+
mongomock==4.1.2
1414
setenv = MONGODB_CONNSTRING = mongodb://localhost:27017
1515
MONGODB_DATABASE = testing_eiffel_graphql_api
1616
commands =
@@ -19,27 +19,27 @@ basepython = python3.6
1919

2020
[testenv:black]
2121
deps =
22-
black
22+
black==22.8.0
2323
commands =
2424
black --check --diff .
2525

2626
[testenv:docs]
2727
deps =
28-
-r docs/requirements.txt
28+
-r docs/requirements.txt
2929
commands =
3030
python setup.py docs
3131

3232
[testenv:pylint]
3333
deps =
34-
pylint
35-
pytest
36-
pytest-cov
37-
mongomock
34+
pylint==2.12.2
35+
pytest==7.0
36+
pytest-cov==4.0.0
37+
mongomock==4.1.2
3838
commands =
3939
pylint src/eiffel_graphql_api tests
4040

4141
[testenv:pydocstyle]
4242
deps =
43-
pydocstyle
43+
pydocstyle==6.3.0
4444
commands =
4545
pydocstyle .

0 commit comments

Comments
 (0)