Skip to content

Commit 76a65e2

Browse files
committed
Reformat with ruff to appease flake8
1 parent d1f4468 commit 76a65e2

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

src/hermes/model/types/ld_context.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,26 @@
1515
PROV_PREFIX = "http://www.w3.org/ns/prov#"
1616
PROV_CONTEXT = [{"prov": PROV_PREFIX}]
1717

18-
HERMES_RT_PREFIX = 'https://schema.software-metadata.pub/hermes-runtime/1.0/'
19-
HERMES_RT_CONTEXT = [{'hermes-rt': HERMES_RT_PREFIX}]
20-
HERMES_CONTENT_CONTEXT = [{'hermes': 'https://schema.software-metadata.pub/hermes-content/1.0/'}]
18+
HERMES_RT_PREFIX = "https://schema.software-metadata.pub/hermes-runtime/1.0/"
19+
HERMES_RT_CONTEXT = [{"hermes-rt": HERMES_RT_PREFIX}]
20+
HERMES_CONTENT_CONTEXT = [
21+
{"hermes": "https://schema.software-metadata.pub/hermes-content/1.0/"}
22+
]
2123

2224
HERMES_CONTEXT = [{**HERMES_RT_CONTEXT[0], **HERMES_CONTENT_CONTEXT[0]}]
2325

24-
HERMES_BASE_CONTEXT = [*CODEMETA_CONTEXT, {**SCHEMA_ORG_CONTEXT[0], **HERMES_CONTENT_CONTEXT[0]}]
25-
HERMES_PROV_CONTEXT = [{**SCHEMA_ORG_CONTEXT[0], **HERMES_RT_CONTEXT[0], **PROV_CONTEXT[0]}]
26+
HERMES_BASE_CONTEXT = [
27+
*CODEMETA_CONTEXT,
28+
{**SCHEMA_ORG_CONTEXT[0], **HERMES_CONTENT_CONTEXT[0]},
29+
]
30+
HERMES_PROV_CONTEXT = [
31+
{**SCHEMA_ORG_CONTEXT[0], **HERMES_RT_CONTEXT[0], **PROV_CONTEXT[0]}
32+
]
2633

27-
ALL_CONTEXTS = [*CODEMETA_CONTEXT, {**SCHEMA_ORG_CONTEXT[0], **PROV_CONTEXT[0], **HERMES_CONTEXT[0]}]
34+
ALL_CONTEXTS = [
35+
*CODEMETA_CONTEXT,
36+
{**SCHEMA_ORG_CONTEXT[0], **PROV_CONTEXT[0], **HERMES_CONTEXT[0]},
37+
]
2838

2939

3040
class ContextPrefix:
@@ -37,6 +47,7 @@ class ContextPrefix:
3747
mapping prefixes to vocabulary IRIs;
3848
- as a dict mapping prefixes to vocabulary IRIs, where the default vocabulary has a prefix of None.
3949
"""
50+
4051
def __init__(self, context):
4152
"""
4253
@param context: A two-item list, where the first item is the default vocabulary's IRI string, and the second
@@ -49,12 +60,13 @@ def __init__(self, context):
4960
if isinstance(ctx, str):
5061
ctx = {None: ctx}
5162

52-
self.prefix.update({
53-
prefix: base_url
54-
for prefix, base_url in ctx.items()
55-
if isinstance(base_url, str)
56-
})
57-
63+
self.prefix.update(
64+
{
65+
prefix: base_url
66+
for prefix, base_url in ctx.items()
67+
if isinstance(base_url, str)
68+
}
69+
)
5870

5971
def __getitem__(self, item): # FIXME Rename parameter to 'key'
6072
"""
@@ -66,9 +78,9 @@ def __getitem__(self, item): # FIXME Rename parameter to 'key'
6678
"""
6779
if not isinstance(item, str):
6880
prefix, name = item
69-
elif ':' in item:
70-
prefix, name = item.split(':', 1)
71-
if name.startswith('://'):
81+
elif ":" in item:
82+
prefix, name = item.split(":", 1)
83+
if name.startswith("://"):
7284
prefix, name = True, item
7385
else:
7486
prefix, name = None, item

0 commit comments

Comments
 (0)