From a99f2c134d5f1177941015ea83c0690aeccfe677 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Thu, 28 Nov 2024 22:14:33 +0100 Subject: [PATCH] Ruff --- datagraph/format.py | 11 ++++++++--- datagraph/schemeld.py | 4 ++-- datagraph/wikidata_ext.py | 8 ++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/datagraph/format.py b/datagraph/format.py index f767362..6fc5444 100644 --- a/datagraph/format.py +++ b/datagraph/format.py @@ -59,7 +59,10 @@ def assert_good_value_repr(r): def to_quickstatements_v1_item( - subject, lines, skip_impossible=True, skip_already_syncronized=True + subject, + lines, + skip_impossible=True, + skip_already_syncronized=True, ): # assert '@id' not in subject, 'TODO: Linked subjects' subject_id = fmt_value(subject, True) if '@id' in subject else 'LAST' @@ -103,12 +106,14 @@ def to_quickstatements_v1_item( if skip_impossible and predicate_str.startswith('"'): logging.warning( - 'Bad line: %s (Lines must not start with ")', predicate_str + 'Bad line: %s (Lines must not start with ")', + predicate_str, ) continue if '' in line and skip_impossible: logging.warning( - 'Bad line: %s (Lines must not contain empty names)', line + 'Bad line: %s (Lines must not contain empty names)', + line, ) continue assert 'None' not in line, line diff --git a/datagraph/schemeld.py b/datagraph/schemeld.py index 0e80438..daa9474 100644 --- a/datagraph/schemeld.py +++ b/datagraph/schemeld.py @@ -21,7 +21,7 @@ class Concept: for k, v in pairs.items(): keys = canonical_keys(k, context) self.pairs.append( - {'canonical_key': keys[0], 'keys': set(keys), 'values': v} + {'canonical_key': keys[0], 'keys': set(keys), 'values': v}, ) self.regenerate_by_keys() @@ -36,7 +36,7 @@ class Concept: 'canonical_key': p['canonical_key'], 'keys': set(p['keys']), 'values': p['values'], - } + }, ) new.regenerate_by_keys() return new diff --git a/datagraph/wikidata_ext.py b/datagraph/wikidata_ext.py index ec3451b..e79337f 100644 --- a/datagraph/wikidata_ext.py +++ b/datagraph/wikidata_ext.py @@ -94,7 +94,8 @@ def get_triples_internal(subject, predicate, object): params['page'] = current_page url = ( requests.Request( - url='https://query.wikidata.org/bigdata/ldf', params=params + url='https://query.wikidata.org/bigdata/ldf', + params=params, ) .prepare() .url @@ -142,6 +143,9 @@ def get_triples(client, subject=None, predicate=None, object=None): def get_backlinks(client, predicate, object): for subject, _, _ in get_triples( - client, subject=None, predicate=predicate, object=object + client, + subject=None, + predicate=predicate, + object=object, ): yield subject