Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure load_from_source doesn't convert None identifier to a bad string #279

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Python PEP 440 Versioning](https://www.python.org/d
## [Unreleased]
- Nothing yet

## [0.29.1] - 2024-12-16

### Added
- Two new basic examples in the Examples folder.
- "sparql_assert_datatype.py" shows how to use SPARQL-based Constraints to assert a datatype on a literal.
- "remote_sparql.py" shows how to use SparqlConnector store to validate data on a remote SPARQL endpoint.

### Fixed
- Fixed a bug where the `identifier` would become "None" (string) in the `load_from_source` function.
- Typos in the example Ontology files in the test suite.


## [0.29.0] - 2024-11-01

### Added
Expand Down Expand Up @@ -1201,7 +1213,8 @@ just leaves the files open. Now it is up to the command-line client to close the

- Initial version, limited functionality

[Unreleased]: https://github.com/RDFLib/pySHACL/compare/v0.29.0...HEAD
[Unreleased]: https://github.com/RDFLib/pySHACL/compare/v0.29.1...HEAD
[0.29.0]: https://github.com/RDFLib/pySHACL/compare/v0.29.0...v0.29.1
[0.29.0]: https://github.com/RDFLib/pySHACL/compare/v0.28.1...v0.29.0
[0.28.1]: https://github.com/RDFLib/pySHACL/compare/v0.28.0...v0.28.1
[0.28.0]: https://github.com/RDFLib/pySHACL/compare/v0.27.0...v0.28.0
Expand Down
14 changes: 8 additions & 6 deletions pyshacl/rdfutil/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,21 @@ def get_rdf_from_web(url: Union[rdflib.URIRef, str]):
# The BaseURI usually ends with a filename (eg, https://example.com/validators/shapes)
# BaseURI can sometimes end with a / if URIs are relative to a directory.
# You will rarely see a BaseURI with a # on the end.
# The PublicID is the Identifier of a Graph. It is the canonical name of the graph,
# regardless of its hosted location. It is used to refer to the graph in a Dataset
# The PublicID is a concept inherited from the XML specificaion
# RDFLib uses PublicID for the Identifier of a Graph. It is the canonical name of the graph,
# regardless of its hosted location. It is also used to refer to a Named Graph in a Dataset
# and this is the name referenced in the owl:imports [ schema:name <publicID> ] statement.
# PublicID is not found in the Turtle file, it is known outside the file only.
# PublicID can end with a / or a # if you want consistency with the graph's base prefix.
# Alternatively, PublicID may not have a symbol at the end.
# Note, PublicID is now called "Identifier" in the load_from_source function.


def load_from_source(
source: Union[GraphLike, BufferedIOBase, TextIOBase, str, bytes],
g: Optional[GraphLike] = None,
rdf_format: Optional[str] = None,
identifier: Optional[str] = None,
identifier: Optional[Union[rdflib.URIRef, str]] = None,
multigraph: bool = False,
do_owl_imports: Union[bool, int] = False,
import_chain: Optional[List[Union[rdflib.URIRef, str]]] = None,
Expand All @@ -146,8 +148,8 @@ def load_from_source(
:type rdf_format: str | None
:param multigraph:
:type multigraph: bool
:param identifier: formerly "public_id"
:type identifier: str | None
:param identifier: Identifier for the Named Graph being loaded. formerly "public_id"
:type identifier: str | URIRef | None
:param do_owl_imports:
:type do_owl_imports: bool|int
:param import_chain:
Expand All @@ -163,7 +165,7 @@ def load_from_source(
source_as_filename: Optional[str] = None
source_as_bytes: Optional[bytes] = None
filename = None
identifier = str(identifier) # This is our passed-in id (formerly public_id)
identifier = None if identifier is None else str(identifier) # This is our passed-in id (formerly public_id)
_maybe_id: Optional[str] = None # For default-graph identifier
base_uri: Optional[str] = None # Base URI for relative URIs
uri_prefix = None # URI Prefix to bind to public ID
Expand Down
Loading