summaryrefslogtreecommitdiff
path: root/rdflib/namespace
Commit message (Collapse)AuthorAgeFilesLines
* fix: eliminate bare `except:` (#2350)Iwan Aucamp2023-04-121-1/+1
| | | | | | | | | | | Replace bare `except:` with `except Exception`, there are some cases where it can be narrowed further, but this is already an improvement over the current situation. This is somewhat pursuant to eliminating [flakeheaven](https://github.com/flakeheaven/flakeheaven), as it no longer supports the latest version of flake8 [[ref](https://github.com/flakeheaven/flakeheaven/issues/132)]. But it also is just the right thing to do as bare exceptions can cause problems.
* fix: correct imports and `__all__` (#2340)Iwan Aucamp2023-04-122-12/+42
| | | | | | | | Disable [`implicit_reexport`](https://mypy.readthedocs.io/en/stable/config_file.html#confval-implicit_reexport) and eliminate all errors reported by mypy after this. This helps ensure that import statements import from the right module and that the `__all__` variable is correct.
* refactor: eliminate inheritance from object (#2339)Iwan Aucamp2023-04-101-1/+1
| | | | | This change removes the redundant inheritance from `object` (i.e. `class Foo(object): pass`) that is no longer needed in Python 3 and is a relic from Python 2.
* refactor: eliminate unused imports (#2337)Iwan Aucamp2023-04-101-2/+0
| | | | | | | `XMLNS` was seen as unused in `rdflib/__init__.py` but this change adds it to `__all__` in that module so that it is not unused. This change also removes actual unused imports in `rdflib/namespace/__init__.py`.
* fix: restore the 6.1.1 default bound namespaces (#2313)Iwan Aucamp2023-03-261-3/+12
| | | | | | | | | | | | The namespaces bound by default by `rdflib.graph.Graph` and `rdflib.namespace.NamespaceManager` was reduced in version 6.2.0 of RDFLib, however, this also would cause code that worked with 6.1.1 to break, so this constituted a breaking change. This change restores the previous behaviour, binding the same namespaces as was bound in 6.1.1. To bind a reduced set of namespaces, the `bind_namespaces` parameter of `rdflib.graph.Graph` or `rdflib.namespace.NamespaceManager` can be used. - Closes <https://github.com/RDFLib/rdflib/issues/2103>.
* fix: change the prefix for `https://schema.org/` back to `schema` (#2312)Iwan Aucamp2023-03-251-3/+3
| | | | | | | The default prefix for `https://schema.org/` registered with `rdflib.namespace.NamespaceManager` was inadvertently changed to `sdo` in 6.2.0, this however constitutes a breaking change, as code that was using the `schema` prefix would no longer have the same behaviour. This change changes the prefix back to `schema`.
* fix: add the `wgs` namespace binding back (#2294)Iwan Aucamp2023-03-211-1/+2
| | | | | | <https://github.com/RDFLib/rdflib/pull/1686> inadvertently removed the `wgs` prefix. This change adds it back. - Closes <https://github.com/RDFLib/rdflib/issues/2196>.
* feat: diverse type hints (#2264)Iwan Aucamp2023-03-121-1/+1
| | | | | | | Add some small diverse type hints. Type hints make RDFLib safer to use and change, as changes and usage can be validated using static analysers like mypy. This change does not have a runtime impact.
* build(deps-dev): bump black from 22.12.0 to 23.1.0 (#2248)dependabot[bot]2023-03-111-3/+0
|
* fix: compute_qname handle case where name could be unbound (#2169)Tom Gillespie2022-12-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * compute_qname handle case where name could be unbound In NamespaceManager.compute_qname it is possible for the variable name to be unbound when a namespace is used as a predicate e.g. ns2: and the namespace itself cannot be split any further. Fixing this usually just kicks the can down the road because the only reason to hit this condition is that you are trying to serialize a predicate that has no valid NCName form into an xml format that requires one, making it impossible to complete the conversion. That said, this fix should make it easier to understand what is going on by unmasking the real issue. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * test_roundtrip.py and n3roundtrip suite add unbound name test The new test graph will produce the UnboundLocalError with the old code that is missing the name = '' assignment. The new code correctly produces the xfail ValueError when trying to convert to xml. Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
* fix: DCTERMS prefix typo (#2173)Nicholas Car2022-12-041-2/+2
| | | The standard prefix for DCTERMS is incorrectly cdterms but it should be dcterms. This is most likely a typo I made some time ago... Fixing now.
* Fix type errors resulting from new mypy (#2161)Iwan Aucamp2022-11-191-1/+2
| | | | | | New mypy version is reporting new errors. In the long run we need to switch to poetry so we can better control this.
* Fallback to old `Store.bind` signature on `TypeError` (#2018)Iwan Aucamp2022-07-151-4/+22
| | | | | | | | | | | | | | If `Store.bind` raises a `TypeError`, and the string conversion of this TypeError contains `override`, then log a warning and call `Store.bind` without an override. This is done so that stores that do not accept `override` on `Store.bind` still work, but at the cost of still having the bug that was fixed by introducing the `override` parameter. Also added a private flag which can be used to disable the fix entirely and never use `override` when calling `Store.bind`. - Fixes https://github.com/RDFLib/rdflib/issues/1880
* [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-05-191-3/+3
| | | | for more information, see https://pre-commit.ci
* Passing "generate" option through in compute_qname_strictMark Watts2022-05-151-2/+2
|
* Raise exception if prefix not bound, expand exception message, add test of ↵Graham Higgins2022-04-271-3/+7
| | | | objects/messages.
* Fix handling of blank CURIE reference and references with multiple colonsIwan Aucamp2022-04-261-9/+8
|
* "principle of least surprise" - return result as URIRef, not strGraham Higgins2022-04-261-2/+2
|
* re-black and adjust testGraham Higgins2022-04-251-1/+3
|
* changes in response to reviewGraham Higgins2022-04-251-13/+8
|
* hazard a guess at type hintingGraham Higgins2022-04-251-1/+2
|
* wrong guess, sighGraham Higgins2022-04-251-1/+1
|
* tsk, forgot to check docstring.Graham Higgins2022-04-251-1/+2
|
* doh!Graham Higgins2022-04-251-3/+1
|
* meh, 3.7 still supported, no walruses :(Graham Higgins2022-04-251-6/+14
|
* resolve issue1869, add a method to expand qname to URIGraham Higgins2022-04-251-0/+20
|
* docs: switch to sphinx-autodoc-typehintsIwan Aucamp2022-04-191-6/+1
| | | | | | | | | | | | | | | | | | | | Currently rdflib is relying on sphinx-autodoc's built in handling for type hints, this however has some deficiencies as it does not handle stuff inside `if TYPE_CHECKING:` and thus only work in cases where there are no potential for circular dependencies. This patch changes sphinx to use sphinx-autodoc-typehints instead, the documentation generated by this plugin looks slightly different but as a positive it correctly works with things defined inside `if TYPE_CHECKING:` guards. Also: - moved the `_NamespaceSetString` type alias to `rdflib._type_checking` This is so that `sphinx-autodoc-typehints` recognizes it up, as it does not handle type aliases that are defined inside `if TYPE_CHECKING:` guards in imported files. - remove sphinx requirements from requirements.dev.txt and replaced it with -r docs/sphinx-requirements.txt to reduce redundancy.
* fix: Raise ValueError for unsupported `bind_namespace` valuesIwan Aucamp2022-04-191-7/+18
| | | | | | | | | | | | This patch changes `NamespaceManager.__init__` to raise a `ValueError` when it receives an unsupported value for `bind_namespaces`. Other changes: - Added a Literal type for valid `bind_namespaces` values, with this type checkers will raise an error if an invalid string is supplied as an argument. - Rename some variables/properties to have a underscore in front to make it clear they are not part of the RDFLib public API.
* fix: DefinedNamespace: fixed handling of control attributes.Iwan Aucamp2022-04-181-3/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes `DefinedNamespace` to always raise `AttributeError` for the name `_NS` and other "control attributes" from `__getattr__`, and to also not consider them as part of the `__dir__`. Without doign this `inspect.signature` recurses infinitely when inspecting `rdflib.namespace.DefinedNamespace` and `dir` results in an `AttributeError`. One situation in which this occurs is when sphinx autodoc is generating documentation from type hints: ``` WARNING: error while formatting signature for rdflib.namespace.DefinedNamespace: Handler <function record_typehints at 0x7fbf2696dd40> for event 'autodoc-process-signature' threw an exception (exception: maximum recursion depth exceeded while calling a Python object) ``` Also: - Changed `DefinedNamespace.__repr__` to use repr for formatting the URI string instead of quoting by hand. This probably has no real effect, as the namespace shoudl not have a double or single quote in it, but it is still correct to use repr. The main reason for this patch is to eliminate a warning for sphinx which is blocking the build since `sphinx.fail_on_warning` was enabled. There is also two cases in `DefinedNamespaceMeta` where an undefined method is being called, these were causing type errors before, but I added notes now to indicate they are real bugs, because if they are reached they just result in `AttributeError` exceptions. This should be fixed sometime, not sure what the reasoning behind it was.
* [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-04-151-1/+0
| | | | for more information, see https://pre-commit.ci
* Merge remote-tracking branch 'upstream/master' into default_prefixesIwan Aucamp2022-04-1528-32/+31
|\
| * [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-04-1528-32/+31
| | | | | | | | for more information, see https://pre-commit.ci
* | Merge branch 'master' into default_prefixesNicholas Car2022-04-151-2/+11
|\ \ | |/
| * Merge pull request #1706 from RDFLib/definednamespace_jsonldNicholas Car2022-04-051-2/+11
| |\ | | | | | | Generate JSON-LD context from a DefinedNamespace
| | * change func name to avoid colisionsNicholas Car2022-03-311-4/+3
| | |
| | * Merge branch 'master' into definednamespace_jsonldNicholas Car2022-03-312-4/+31
| | |\
| | * | Update rdflib/namespace/__init__.pyNicholas Car2022-02-131-1/+1
| | | | | | | | | | | | Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
| | * | Update __init__.pyNicholas Car2022-02-111-1/+1
| | | |
| | * | Update rdflib/namespace/__init__.pyNicholas Car2022-02-111-1/+1
| | | | | | | | | | | | Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
| | * | add jsonld_context() function to DefinedNamespacenicholascar2022-02-071-2/+12
| | | |
* | | | Update rdflib/namespace/__init__.pyNicholas Car2022-04-051-3/+0
| | | | | | | | | | | | Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
* | | | [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-04-041-2/+9
| | | | | | | | | | | | | | | | for more information, see https://pre-commit.ci
* | | | Merge remote-tracking branch 'upstream/master' into default_prefixesIwan Aucamp2022-04-041-6/+8
|\ \ \ \ | |/ / /
| * | | Only check for is_valid_uri if not already cachedGraham Higgins2022-03-281-6/+7
| | |/ | |/|
* | | Fix issues with NamespaceManager.bindIwan Aucamp2022-03-311-10/+9
| | | | | | | | | | | | | | | | | | replace and override handling is now correct as far as I can tell. Also added some tests.
* | | Fix type errorIwan Aucamp2022-03-311-0/+4
| | |
* | | remove printsnicholascar2022-03-301-6/+0
| | |
* | | ensure all core Stores contain prefix replace optionnicholascar2022-03-301-15/+24
| | |
* | | 'none' optionnicholascar2022-03-281-4/+10
| | |
* | | docco improvementsnicholascar2022-03-271-16/+23
| | |