summaryrefslogtreecommitdiff
path: root/rdflib/plugins/serializers
Commit message (Collapse)AuthorAgeFilesLines
* fix: eliminate bare `except:` (#2350)Iwan Aucamp2023-04-123-5/+5
| | | | | | | | | | | 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.
* refactor: eliminate inheritance from object (#2339)Iwan Aucamp2023-04-102-2/+2
| | | | | 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.
* feat: add typing to `rdflib.util` (#2262)Iwan Aucamp2023-03-121-1/+2
| | | | | | | | Mainly so that users can use RDFLib in a safer way, and that we can make safer changes to RDFLib in future. There are also some accomodating type-hint related changes outside of `rdflib.util`. This change does not have a runtime impact.
* feat: diverse type hints (#2264)Iwan Aucamp2023-03-122-7/+14
| | | | | | | 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-116-14/+0
|
* feat: do not write prefix for empty graph id (#2160)Elie Roux2022-12-301-0/+3
| | | Since the names of empty graphs do not appear in the serialization, do not consider them for namespace issues.
* fix: issue with trig reference counting across graphs (#2085)Iwan Aucamp2022-08-241-9/+5
| | | | | | | | | | | | | | | | | | | | | The TriG serializer was only considering BNode references inside a single graph and not counting the BNodes subjects as references when considering if a BNode should be serialized as unlabeled blank nodes (i.e. `[ ]`), and as a result it was serializing BNodes as unlabeled if they were in fact referencing BNodes in other graphs. One caveat of this change is that some RDF Datasets may be serialized less succinctly in that unlabeled blank nodes would not be used nodes where it is technically possible to use them. This can be trivially fixed, but a trivial fix increases the computational complexity of serialization significantly. Other changes: - Removed the roundtrip xfail that this change fixed. - Added another roundtrip test which has various combinations of BNode references across graphs in a dataset, this test fails for JSON-LD however, so while this change removes one xfail it also now adds another. - Set the default indent_size and style in `.editorconfig` as to avoid relying on undefined system defaults.
* add chunk serializer & tests (#1968)Nicholas Car2022-08-121-10/+23
| | | | | | | | | This file provides a single function `serialize_in_chunks()` which can serialize a Graph into a number of NT files with a maximum number of triples or maximum file size. There is an option to preserve any prefixes declared for the original graph in the first file, which will be a Turtle file. Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
* Remove extra newline from N-Triples output (#1999)Tom Mitchell2022-06-241-1/+0
| | | | | | | Remove the extra newline generated by the N-Triples serializer and add a unit test to verify that N-Triples output does not end in two consecutive newlines. Closes #1998
* More type hints for `rdflib.graph` and related (#1853)Iwan Aucamp2022-05-261-3/+6
| | | | | | | | | | | | | | | | | | 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
* fix sonarcloud-reported bug in xmlwriter, add test (#1951)Graham Higgins2022-05-251-1/+1
| | | | | | | | | | | | | | | sonarcloud detected a bug: “Remove 1 unexpected arguments; 'join' expects 1 positional arguments.” in xmlwriter: ```py return ":".join(pre, uri[len(ns) :]) ``` Added containing brackets apparently omitted by original author. ```py return ":".join([pre, uri[len(ns) :]]) ``` Added test for surety, took the opportunity of adding two tests to take coverage of `xmlwriter` to 100%.
* fix for sonarcloud-reported bug (#1945)Graham Higgins2022-05-251-1/+1
| | | | | invalid "+" operation between incompatible types (str and type) - [sonarcloud-reported bug](https://sonarcloud.io/project/issues?issues=AYDHhHV9L8VDMGmTmRtc&open=AYDHhHV9L8VDMGmTmRtc&id=RDFLib_rdflib) Changed exception string construction to use `f""` format
* fix: two issues with the N3 serializerIwan Aucamp2022-05-161-30/+3
| | | | | | | | | | | | | | | | | | | | | This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - https://github.com/RDFLib/rdflib/issues/1807 - https://github.com/RDFLib/rdflib/issues/1701
* [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-04-1511-42/+37
| | | | for more information, see https://pre-commit.ci
* Merge pull request #1697 from ↵Iwan Aucamp2022-03-031-6/+8
|\ | | | | | | | | | | | | ajnelson-nist/apply_identified_node_to_graph_iterators Apply IdentifiedNode to Graph iterators Merging with only one review as this just add type hints with one minor exception that involves well tested code.
| * [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-02-231-1/+3
| | | | | | | | for more information, see https://pre-commit.ci
| * Remove unused type ignoresIwan Aucamp2022-02-231-2/+2
| |
| * Fix type checking errorsIwan Aucamp2022-02-221-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | Type checking passes now. I also included some changes which reduces the footprint of this change so that it becomes almost entirely just change of type annotations. This may be a bit on the pendatic side, and I would be fine if you keep the changes as they were, but I would rather keep refactoring seperate from changes to add typing.
| * Apply IdentifiedNode type signature revisions to rdf-xml serializerAlex Nelson2022-01-251-4/+6
| | | | | | | | | | | | | | | | | | | | This resolves type signature issues raised in the prior patch, but might require a follow-on patch depending on `Path` discussion. References: * https://github.com/RDFLib/rdflib/issues/1696 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
* | Fix turtle serialization of PNames that contain bracketsIwan Aucamp2022-01-301-0/+3
| | | | | | | | | | | | | | | | | | | | Brackets in pnames will now be escaped in output. This fix is based on a suggestion by Niklas Lindström (@niklasl). This is somewhat of a stopgap fix, there are some problems being masked and various cases that could still result in questionable Turtle being written out, however these can be addressed seperately.
* | Merge pull request #1684 from aucampia/iwana-20220123T0031-jsonld_rdf_prefixIwan Aucamp2022-01-301-1/+2
|\ \ | | | | | | Merging as fix is trivial and PR has one review.
| * | Fix turtle serialization of `rdf:type` in subject and objectIwan Aucamp2022-01-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously if `rdf:type` occurred in subject or object of a triple then turtle would have not added a prefix for rdf as it considered `rdf:type` to be a keyword regardless of where in the triple it occurred. This changeset ensures that rdf:type is only considered a keyword if it occurs as the predicate of a triple.
* | | Merge pull request #1683 from aucampia/iwana-20220122T0119-term_typingIwan Aucamp2022-01-301-0/+1
|\ \ \ | |_|/ |/| | Merging pull request as it contains only type changes and has one review.
| * | Add typing to rdflib.termIwan Aucamp2022-01-221-0/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds as much typing as possible to `rdflib.term`. Other changes: - Added back `warn_unused_ignores`. I actually thought this was enabled but I forgot I disabled it because of some issue on python 3.10. - Disabled `warn_unused_ignores` only for `rdflib.plugin`. There is an ignore in this module which is not needed on python 3.10, this is the most targetted way to avoid having that fail the type checking that I can think of for now. - Removed unused type ignores. This changeset includes no runtime changes.
* | fix: format with blackeggplants2022-01-241-8/+13
|/ | | | $ black --config black.toml .
* Update rdflib/plugins/serializers/hext.pyNicholas Car2022-01-101-1/+1
| | | Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
* Update rdflib/plugins/serializers/hext.pyNicholas Car2022-01-101-0/+1
| | | Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
* allow hext to participate in RDF format roundtrippingnicholascar2022-01-091-4/+7
|
* Merge pull request #1473 from RDFLib/drone_py310Nicholas Car2021-12-171-2/+2
|\ | | | | Add Py 3.10 to testing envs
| * style fixes onlynicholascar2021-12-161-2/+2
| |
* | modernize warning string constructionGraham Higgins2021-12-123-6/+5
|/
* fixing MyPy errorshextuplesnicholascar2021-12-091-1/+1
|
* more Flak8 improvementsnicholascar2021-12-072-2/+8
|
* ignore Flake Error W505 as soon it won't be considered an errornicholascar2021-12-071-2/+2
|
* backing all filesnicholascar2021-12-071-1/+1
|
* Flak8 improvementsnicholascar2021-12-074-14/+14
|
* blacked parsers & serializersnicholascar2021-12-077-12/+16
|
* match serialize() super function signaturenicholascar2021-12-071-3/+11
|
* isinstance() instead of type()nicholascar2021-12-071-9/+9
|
* exclude hext from rountrip testing; add hext own troundrip tests, update ↵nicholascar2021-12-071-53/+69
| | | | hext format
* some roundftripling tests; better default graph IRI ('""')nicholascar2021-12-061-1/+1
|
* fix hext serializer to always indicate string literals with datatypenicholascar2021-12-061-5/+8
|
* fixed multiline JSON representationnicholascar2021-12-041-1/+0
|
* fixed boolean JSOn representationnicholascar2021-12-041-1/+33
|
* improve hext and nt encoding - all utf-8nicholascar2021-12-042-11/+14
|
* ensure both context aware and not worknicholascar2021-12-031-6/+17
|
* basic hextuples serializernicholascar2021-12-031-0/+54
|
* rename turtle2 longturtle; update parser & plubing docconicholascar2021-12-031-13/+10
|
* Add type hintsIwan Aucamp2021-10-247-29/+90
| | | | | | | This commit only adds type hints and comments and does not make any changes that should affect runtime. The type hints added here derive from work done for #1418.
* updated commentsNicholas Car2021-10-021-36/+9
|