| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the handling of HTTP status code 308 to behave more like
`urllib.request.HTTPRedirectHandler`, most critically, the new 308 handling will
create a new `urllib.request.Request` object with the new URL, which will
prevent state from being carried over from the original request.
One case where this is important is when the domain name changes, for example,
when the original URL is `http://www.w3.org/ns/adms.ttl` and the redirect URL is
`https://uri.semic.eu/w3c/ns/adms.ttl`. With the previous behaviour, the redirect
would contain a `Host` header with the value `www.w3.org` instead of
`uri.semic.eu` because the `Host` header is placed in
`Request.unredirected_hdrs` and takes precedence over the `Host` header in
`Request.headers`.
Other changes:
- Only handle HTTP status code 308 on Python versions before 3.11 as Python 3.11
will handle 308 by default [[ref](https://docs.python.org/3.11/whatsnew/changelog.html#id128)].
- Move code which uses `http://www.w3.org/ns/adms.ttl` and
`http://www.w3.org/ns/adms.rdf` out of `test_guess_format_for_parse` into a
separate parameterized test, which instead uses the embedded http server.
This allows the test to fully control the `Content-Type` header in the
response instead of relying on the value that the server is sending.
This is needed because the server is sending `Content-Type: text/plain` for
the `adms.ttl` file, which is not a valid RDF format, and the test is
expecting `Content-Type: text/turtle`.
Fixes:
- <https://github.com/RDFLib/rdflib/issues/2382>.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Eliminate some occurrences of the following flake8 errors in tests:
* E265 block comment should start with '# '
* E266 too many leading '#' for block comment
* E402 module level import not at top of file
* E712 comparison to False should be 'if cond is False:' or 'if not cond:'
* E712 comparison to True should be 'if cond is True:' or 'if cond:'
* E722 do not use bare 'except'
* F401 ... imported but unused
* F403 ... used; unable to detect undefined names
* F405 ... may be undefined, or defined from star imports: ...
* F541 f-string is missing placeholders
* F841 local variable 'result' is assigned to but never used
* N806 variable 'TEST_DIR' in function should be lowercase
This is 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)].
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
DESCRIBE queries (#2322)
Add optional keyword only `target_graph` argument to `rdflib.graph.Graph.cbd` and use this new argument in `evalDescribeQuery`.
This makes it possible to compute a concise bounded description without creating a new graph to hold the result, and also without potentially having to copy it to another final graph.
Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
|
| |
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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>.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The URI to IRI conversion was percentage-quoting characters that should not have
been quoted, like equals in the query string. It was also not quoting things
that should have been quoted, like the username and password components of a
URI.
This change improves the conversion by only quoting characters that are not
allowed in specific parts of the URI and quoting previously unquoted components.
The safe characters for each segment are taken from
[RFC3986](https://datatracker.ietf.org/doc/html/rfc3986).
The new behavior is heavily inspired by
[`werkzeug.urls.iri_to_uri`](https://github.com/pallets/werkzeug/blob/92c6380248c7272ee668e1f8bbd80447027ccce2/src/werkzeug/urls.py#L926-L931)
though there are some differences.
- Closes <https://github.com/RDFLib/rdflib/issues/2120>.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
build(deps-dev): bump mypy from 1.0.1 to 1.1.1
Bumps [mypy](https://github.com/python/mypy) from 1.0.1 to 1.1.1.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v1.0.1...v1.1.1)
updated-dependencies:
- dependency-name: mypy
dependency-type: direct:development
update-type: version-update:semver-minor
Also added type ignores for newly detected type errors.
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I have added a bunch of tests for `InputSource` handling, checking
most kinds of input source with most parsers. During this, I detected
the following issues that I fixed:
- `rdflib.util._iri2uri()` was URL quoting the `netloc` parameter, but
this is wrong and the `idna` encoding already takes care of special
characters. I removed the URL quoting of `netloc`.
- HexTuple parsing was handling the input source in a way that would
only work for some input sources, and not raising errors for other
input sources. I changed the input source handling to be more generic.
- `rdflib.parser.create_input_source()` incorrectly used `file.buffer`
instead of `source.buffer` when dealing with IO stream sources.
Other changes with no runtime impact include:
- Changed the HTTP mocking stuff in test slightly to accommodate
serving arbitrary files, as I used this in the `InputSource` tests.
- Don't use Google in tests, as we keep getting
`urllib.error.HTTPError: HTTP Error 429: Too Many Requests`
from it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* build(deps-dev): bump mypy from 0.991 to 1.0.1
Bumps [mypy](https://github.com/python/mypy) from 0.991 to 1.0.1.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.991...v1.0.1)
---
updated-dependencies:
- dependency-name: mypy
dependency-type: direct:development
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
* fix type errors
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
system (#2096)
This is so that it is simpler and easier to do something with all plugins without treating different plugins in different ways.
Also remove test code that tries to accommodate the plugin being present but not usable.
Fixes #1816
|
| |
|
|
|
|
| |
Confirm various content type values are handled correctly with CONSTRUCT
queries and SPARQLStore.
This aims to confirm that #1195 is fixed.
|
| |
|
|
|
|
|
|
|
|
| |
Always parse HexTuple files as utf-8 as was the intent anyway as
evidenced by the code that will raise a warning if the encoding provided
for a HexTuple file is something other than utf-8 or None.
https://github.com/RDFLib/rdflib/blob/cfa418074b27b12aac905ba266b002a237c5ff4c/rdflib/plugins/parsers/hext.py#L73-L79
Not adding any tests as this code is already tested and an XFAIL is
removed in this patch.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This is to confirm that `graph_diff` does not work with quads.
Other changes:
- Added support to `GraphHelper` for collapsing `BNode`s to a specific IRI
when converting to triple sets, this is in addition to the current
functionality for ignoring BNodes. This makes it possible to more
accurately compare Graphs that contain blank nodes.
- Added `assert_cgraph_isomorphic` to `GraphHelper`.
This method adds some rudimentary support for checking if conjunctive
graphs are isomorphic, it will ignore named graphs that have blank
nodes as name.
|
| |
|
|
| |
This patch converts some additional graph tests to pytest, I'm doing
this in preperation for adding more tests to `test_diff.py`.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch primarily adds more type hints for `rdflib.graph`, but also
adds type hints to some related modules in order to work with the new
type hints for `rdflib.graph`.
I'm mainly doing this as a baseline for adding type hints to
`rdflib.store`.
I have created type aliases to make it easier to type everything
consistently and to make type hints easier easier to change in the
future. The type aliases are private however (i.e. `_`-prefixed) and
should be kept as such for now.
This patch only contains typing changes and does not change runtime
behavior.
Broken off from https://github.com/RDFLib/rdflib/pull/1850
|
| |
|
|
| |
for more information, see https://pre-commit.ci
|
| |
|
|
|
|
|
| |
Add an iri-to-uri conversion utility to encode IRIs to URIs for `Graph.parse()` sources. Added a couple of tests because feeding it with a suite of IRIs to check seems overkill (not that I could find one).
Fixes #1429
Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
|
| |
|
|
|
|
|
|
| |
This is being done because `rdlib.net` is a typo and `rdflib.net` is not owned or associated with this project.
Also:
- Expand testing for some parts of the code impacted by this.
Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
SPARQL (#1872)
This patch adds test to verify that forward-slashes, and escaped forward slashes, work correctly in Turtle, JSON-LD and SPARQL.
Some of the added tests check that SPARQL queries that contain seemingly escaped forward slashes as part of `PN_LOCAL` fail to execute as the SPARQL spec does not allow for escaped forward slashes in `PN_LOCAL`.
Currently the RDFLib SPARQL processor does however allow escaped forward slashes as part of `PN_LOCAL`, so these tests have been marked with xfail as RDFLib should provide some way to parse SPARQL in strict mode, and in this mode leaniancies should be disabled and any non-standard SPARQL should be treated as invalid.
Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
|
| |
|
|
|
|
| |
This is a fairly straight forward conversion to pytest.
Also:
- Fix/ignore some flake8 errors.
|
| |
|
|
|
|
|
|
|
|
| |
This patch removes unused imports in test code. This is mainly to remove
the potential snag for flake8/flakeheaven.
The actual cleanup was done with `pycln --all test`.
Also:
- Remove superflous `pass` statements.
|
| |
|
|
|
| |
We have added a test for the example at the definition for Concise Bounded Definition [here](https://www.w3.org/Submission/CBD/#example).
Fixes #1914
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds some additional graph variants:
- diverse_triples: More than one triple using various features.
- diverse_quads: More than one quad in more than one graph using various
features.
- more_quads: Simple quads in more than one graph.
This also highlights some additional issues:
- There is a bug in JSON-LD and HexTuple serialization that drops
datatypes.
- The TriG parser gets confused about what graph a quad is in.
- There is some encoding related issue with HexTuple parsing on windows.
|
| |
|
|
|
| |
This changes the HTTP server mock to a more versatile implementation
with support for more HTTP methods.
|
| |
|
|
| |
- update to use new test utils structure
|
| |
|
|
|
|
|
| |
This patch moves all test utility modules into `test/utils/` and the
tests for these modules into `test/utils/test/`.
This is to make test utilities more organized and in preparation for
adding more test utilities related to test suites.
|
| |
|
|
| |
This is to bring it in line with other test data.
|
| |
|
|
|
|
|
|
|
|
|
| |
- Added store specific tests for namespace binding and rebinding.
- Copied @gjhiggins fix for `rdflib.plugins.stores.memory.Memory.bind` to
`rdflib.plugins.stores.memory.SimpleMemory.bind`.
- Changed `bind` on `Memory`, `SimpleMemory`, `BerkleyDB` stores to
explicitly check for `is not None`/`is None` instead of
falsey/truthy.
- Added `pytest.util._coalesce` to do null coalescing, for more info see
deferred PEP-505 https://peps.python.org/pep-0505/.
|
| |
|
|
| |
for more information, see https://pre-commit.ci
|
| | |
|
| |\
| |
| | |
Fix issue 1808
|
| | | |
|
| |\ \
| |/ |
|
| | |
| |
| |
| | |
for more information, see https://pre-commit.ci
|
| |/ |
|
| |\
| |
| |
| |
| | |
Migrate to pytest, relocate in subfolder
Merging with only one approval as the coverage remains the same and it only affects tests.
|
| | | |
|
| | | |
|
| | | |
|
| |/
|
|
| |
for more information, see https://pre-commit.ci
|
| |\
| |
| |
| |
| | |
Add two xfails related to Example 2 from RDF 1.1 TriG specification
Merging with only one review as this just adds tests within the variant and round trip test harnesses which are parameterized. Some of the added tests are xfails but given that the rest of the tests for the same parameterized harnesses pass it seems likely that the xfail tests are valid.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The first xfail occurs during round tripping, TriG seems to be making
some mistake when encoding blank nodes, as it is encoding that "Bob"
knows someone who does not exist. This was reported by @gjhiggins in
https://github.com/RDFLib/rdflib/pull/1796#discussion_r846781069
The second xfail seems to be related to hextuple parsing, when comparing
the hextuple parsed result of Example 2 with the TriG parsed
graph of Example 2 the graphs are not isomorphic more than 70% of the time, but
sometimes they are isomorphic. Inoticed this while adding the xfail for
the issue @gjhiggins noticed.
Other changes:
- Added `simple_quad` to variants tests with HexTuple and TriG format.
- Added an additional exact_match assert for variants which can be used
to sidestep some of the known issues with isomorphic graph detection.
This is useful for graphs with no BNodes.
- Also added round-tripping for `variants/simple_quad.trig`.
- Various changes to ensure determensitic ordering so that it is easier
to compare things visually and so that tests always do the exact same
thing in the exact same order.
|
| | | |
|
| | | |
|
| |/ |
|
| | |
|
| | |
|