Skip to content

Commit

Permalink
Merge branch 'fix-issue-1808' of https://github.com/edmondchuc/rdflib
Browse files Browse the repository at this point in the history
…into fix-issue-1808
  • Loading branch information
edmondchuc committed Apr 15, 2022
2 parents 5a59893 + f47c379 commit b5703b9
Show file tree
Hide file tree
Showing 284 changed files with 5,340 additions and 4,250 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trim_trailing_whitespace = false
[*.{js,py,pyi,toml,yml,yaml}]
charset = utf-8

[*.{yaml,yml,json}]
[*.{yaml,yml,json,jsonld}]
indent_style = space
indent_size = 2

Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,37 +104,3 @@ jobs:
export TOXENV
export TOX_EXTRA_COMMAND="${{ matrix.TOX_EXTRA_COMMAND }}"
"${test_harness[@]}" python -m tox
docs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tox-env: ["docs"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{env.DEFAULT_PYTHON}}
uses: actions/setup-python@v2
with:
python-version: ${{env.DEFAULT_PYTHON}}
- name: Get pip cache dir
id: pip-cache
shell: bash
run: |
python -m ensurepip --upgrade
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: tox-${{ matrix.tox-env }}-pip-v1-${{
hashFiles('**/setup.py', '**/requirements*.txt') }}
restore-keys: |
tox-${{ matrix.tox-env }}-pip-v1-
- name: Install dependencies
shell: bash
run: |
python -m pip install tox tox-gh-actions
- name: Run ${{ matrix.tox-env }}
shell: bash
run: |
python -m tox -e ${{ matrix.tox-env }}
3 changes: 3 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ python:
path: .
extra_requirements:
- docs

sphinx:
fail_on_warning: true
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ The RDFlib community maintains many RDF-related Python code repositories with di
* [rdflib](https://github.com/RDFLib/rdflib) - the RDFLib core
* [sparqlwrapper](https://github.com/RDFLib/sparqlwrapper) - a simple Python wrapper around a SPARQL service to remotely execute your queries
* [pyLODE](https://github.com/RDFLib/pyLODE) - An OWL ontology documentation tool using Python and templating, based on LODE.
* [pyrdfa3](https://github.com/RDFLib/pyrdfa3) - RDFa 1.1 distiller/parser library: can extract RDFa 1.1/1.0 from (X)HTML, SVG, or XML in general.
* [pymicrodata](https://github.com/RDFLib/pymicrodata) - A module to extract RDF from an HTML5 page annotated with microdata.
* [pySHACL](https://github.com/RDFLib/pySHACL) - A pure Python module which allows for the validation of RDF graphs against SHACL graphs.
* [OWL-RL](https://github.com/RDFLib/OWL-RL) - A simple implementation of the OWL2 RL Profile which expands the graph with all possible triples that OWL RL defines.

Please see the list for all packages/repositories here:

* <https://github.com/RDFLib>

Help with maintenance of all of the RDFLib family of packages is always welcome and appreciated.

## Versions & Releases

* `6.2.0-alpha` current `master` branch
Expand Down
2 changes: 1 addition & 1 deletion admin/get_merged_prs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Get all merged PRs since last release, save them to a JSON file"""

import httpx
import json
from datetime import datetime

import httpx

r = httpx.get(
"https://api.github.com/repos/rdflib/rdflib/pulls",
Expand Down
8 changes: 7 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import re
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -243,3 +243,9 @@ def find_version(filename):
html_experimental_html5_writer = True

needs_sphinx = "4.1.2"

suppress_warnings = [
# This is here to prevent:
# "WARNING: more than one target found for cross-reference"
"ref.python",
]
4 changes: 2 additions & 2 deletions docs/developers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ met:

There should either be existing tests that cover the changed code and
behaviour, or the PR should include tests. For more information about what is
considered adequate testing see the :ref:`Tests section <Tests>`.
considered adequate testing see the :ref:`Tests section <tests>`.

* Documentation that covers something that changed has been updated.

Expand All @@ -65,7 +65,7 @@ the users of this project.
Please note that while we would like all PRs to follow the guidelines given
here, we will not reject a PR just because it does not.

.. Tests:
.. _tests:

Tests
-----
Expand Down
116 changes: 58 additions & 58 deletions docs/rdf_terms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,64 @@ All terms in RDFLib are sub-classes of the :class:`rdflib.term.Identifier` class
:caption: Term Class Hierarchy
:type: plantuml

@startuml
skinparam shadowing false
skinparam monochrome true
skinparam packageStyle rectangle
skinparam backgroundColor FFFFFE

class Node

class Identifier {
eq(other) -> bool
neq(other) -> bool
startswith(prefix: str, start, end) -> bool
}
Identifier -up-|> Node
class IdentifiedNode {
toPython() -> str
}
IdentifiedNode -up-|> Identifier
class URIRef {
n3(namespace_manager) -> str
defrag() -> URIRef
de_skolemize() -> BNode
}
URIRef -up-|> IdentifiedNode

class Genid
Genid -up-|> URIRef
class RDFLibGenid
RDFLibGenid -up-|> Genid
class BNode {
n3(namespace_manager) -> str
skolemize(authority, basepath) -> RDFLibGenid
}
BNode -up-|> IdentifiedNode
class Literal {
datatype: Optional[str]
lang: Optional[str]
value: Any

normalize() -> Literal
n3(namespace_manager) -> str
toPython() -> str
}
Literal -up-|> Identifier
class Variable {
n3(namespace_manager) -> str
toPython() -> str
}
Variable -up-|> Identifier
@enduml
@startuml
skinparam shadowing false
skinparam monochrome true
skinparam packageStyle rectangle
skinparam backgroundColor FFFFFE
class Node
class Identifier {
eq(other) -> bool
neq(other) -> bool
startswith(prefix: str, start, end) -> bool
}
Identifier -up-|> Node
class IdentifiedNode {
toPython() -> str
}
IdentifiedNode -up-|> Identifier
class URIRef {
n3(namespace_manager) -> str
defrag() -> URIRef
de_skolemize() -> BNode
}
URIRef -up-|> IdentifiedNode
class Genid
Genid -up-|> URIRef
class RDFLibGenid
RDFLibGenid -up-|> Genid
class BNode {
n3(namespace_manager) -> str
skolemize(authority, basepath) -> RDFLibGenid
}
BNode -up-|> IdentifiedNode
class Literal {
datatype: Optional[str]
lang: Optional[str]
value: Any
normalize() -> Literal
n3(namespace_manager) -> str
toPython() -> str
}
Literal -up-|> Identifier
class Variable {
n3(namespace_manager) -> str
toPython() -> str
}
Variable -up-|> Identifier
@enduml

Nodes are a subset of the Terms that the underlying store actually persists.
The set of such Terms depends on whether or not the store is formula-aware.
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ exclude = '''
| htmlcov
| benchmarks
| examples # No need to Black examples
| test # Tests are a mess, don't black them
| test_reports
| rdflib.egg-info
| buck-out
Expand Down
14 changes: 5 additions & 9 deletions rdflib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
"util",
]

import sys
import logging
import sys

logger = logging.getLogger(__name__)

Expand All @@ -97,6 +97,7 @@
if (
not hasattr(__main__, "__file__")
and sys.stdout is not None
and hasattr(sys.stderr, "isatty")
and sys.stderr.isatty()
):
# show log messages in interactive mode
Expand Down Expand Up @@ -156,13 +157,8 @@
Literal work, eq, __neq__, __lt__, etc.
"""

from rdflib.term import URIRef, BNode, IdentifiedNode, Literal, Variable

from rdflib.graph import Dataset, Graph, ConjunctiveGraph

from rdflib import plugin
from rdflib import query

from rdflib import plugin, query
from rdflib.graph import ConjunctiveGraph, Dataset, Graph
from rdflib.namespace import (
BRICK,
CSVW,
Expand Down Expand Up @@ -192,11 +188,11 @@
XSD,
Namespace,
)
from rdflib.term import BNode, IdentifiedNode, Literal, URIRef, Variable

# tedious sop to flake8
assert plugin
assert query

from rdflib import util

from rdflib.container import *
4 changes: 1 addition & 3 deletions rdflib/collection.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from rdflib.namespace import RDF
from rdflib.term import BNode
from rdflib.term import Literal

from rdflib.term import BNode, Literal

__all__ = ["Collection"]

Expand Down
27 changes: 12 additions & 15 deletions rdflib/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@
_:cb558f30e21ddfc05ca53108348338ade8
<http://example.org/ns#label> "B" .
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from __future__ import absolute_import, division, print_function

# TODO:
# - Doesn't handle quads.
Expand All @@ -92,24 +89,24 @@
"similar",
]

from rdflib.graph import Graph, ConjunctiveGraph, ReadOnlyGraphAggregate
from rdflib.term import BNode, Node, URIRef, IdentifiedNode
from hashlib import sha256

from datetime import datetime
from collections import defaultdict
from datetime import datetime
from hashlib import sha256
from typing import (
Set,
Dict,
TYPE_CHECKING,
Union,
List,
Tuple,
Callable,
Optional,
Dict,
Iterator,
List,
Optional,
Set,
Tuple,
Union,
)

from rdflib.graph import ConjunctiveGraph, Graph, ReadOnlyGraphAggregate
from rdflib.term import BNode, IdentifiedNode, Node, URIRef

if TYPE_CHECKING:
from _hashlib import HASH

Expand Down
13 changes: 1 addition & 12 deletions rdflib/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
and different versions of support libraries.
"""

import re
import codecs
import re
import warnings
from typing import TYPE_CHECKING, Match


if TYPE_CHECKING:
import xml.etree.ElementTree as etree
else:
Expand All @@ -18,16 +17,6 @@
import xml.etree.ElementTree as etree


try:
etree_register_namespace = etree.register_namespace
except AttributeError:

import xml.etree.ElementTree as etreenative

def etree_register_namespace(prefix, uri):
etreenative._namespace_map[uri] = prefix


def cast_bytes(s, enc="utf-8"):
if isinstance(s, str):
return s.encode(enc)
Expand Down
3 changes: 2 additions & 1 deletion rdflib/container.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from random import randint

from rdflib.namespace import RDF
from rdflib.term import BNode, URIRef
from random import randint

__all__ = ["Container", "Bag", "Seq", "Alt", "NoElementException"]

Expand Down
Loading

0 comments on commit b5703b9

Please sign in to comment.