RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.15k stars 555 forks source link

feat: update DOAP namespace #2869

Closed raboof closed 1 month ago

raboof commented 2 months ago

Summary of changes

Including updates to rdflib/tools/defined_namespace_creator.py so fewer manual changes are needed.

Fixes #2811

Checklist

ashleysommer commented 1 month ago

@nicholascar Looks like required tests were not run on this PR, it introduced 2 mypy typing errors, that are now in main branch, affecting all other PRs.

EDIT: 2, not 6.

raboof commented 1 month ago

ouch, sorry about that, I'll have a look

raboof commented 1 month ago

can you clarify how you invoke mypy? When I poetry run mypy --show-error-context --show-error-codes as described in https://rdflib.readthedocs.io/en/latest/developers.html#running-static-checks I'm getting errors in code I didn't change as well:

Creating virtualenv rdflib-MH8QKPnW-py3.12 in /home/aengelen/.cache/pypoetry/virtualenvs
rdflib/query.py:160: error: Unused "type: ignore[type-var]" comment  [unused-ignore]
rdflib/graph.py:1785: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/graph.py:1829: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/graph.py:2000: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/graph.py:2003: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/graph.py:2798: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/graph.py:2817: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/graph.py:2820: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/graph.py:2987: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/graph.py:2990: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/plugins/sparql/operators.py: note: In function "simplify":
rdflib/plugins/sparql/operators.py:991: error: Statement is unreachable  [unreachable]
rdflib/plugins/sparql/algebra.py: note: In function "_traverse":
rdflib/plugins/sparql/algebra.py:414: error: Statement is unreachable  [unreachable]
rdflib/plugins/sparql/algebra.py:421: error: Statement is unreachable  [unreachable]
rdflib/plugins/sparql/algebra.py: note: In function "_traverseAgg":
rdflib/plugins/sparql/algebra.py:439: error: Statement is unreachable  [unreachable]
rdflib/tools/defined_namespace_creator.py: note: In function "make_dn_file":
rdflib/tools/defined_namespace_creator.py:148: error: Argument 1 to "len" has incompatible type "Iterable[str]"; expected "Sized"  [arg-type]
rdflib/plugins/sparql/results/xmlresults.py:257: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/plugins/sparql/results/xmlresults.py:287: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/plugins/parsers/trix.py: note: In member "startElementNS" of class "TriXHandler":
rdflib/plugins/parsers/trix.py:108: error: Incompatible types in assignment (expression has type "str", variable has type "None")  [assignment]
rdflib/plugins/parsers/trix.py:108: error: Argument 1 to "getValue" of "AttributesImpl" has incompatible type "Tuple[str, str]"; expected "str"  [arg-type]
rdflib/plugins/parsers/trix.py:113: error: Incompatible types in assignment (expression has type "str", variable has type "None")  [assignment]
rdflib/plugins/parsers/trix.py:125: error: Incompatible types in assignment (expression has type "str", variable has type "None")  [assignment]
rdflib/plugins/parsers/trix.py:125: error: Argument 1 to "getValue" of "AttributesImpl" has incompatible type "Tuple[str, str]"; expected "str"  [arg-type]
rdflib/plugins/parsers/trix.py: note: In member "parse" of class "TriXParser":
rdflib/plugins/parsers/trix.py:287: error: "ContentHandler" has no attribute "preserve_bnode_ids"  [attr-defined]
test/test_namespace/test_definednamespace_creator.py: note: In function "test_get_target_namespace_elements":
test/test_namespace/test_definednamespace_creator.py:172: error: Statement is unreachable  [unreachable]
test/test_extras/test_shacl_extras.py:215: error: Unused "type: ignore" comment  [unused-ignore]
rdflib/plugins/parsers/rdfxml.py: note: In member "startElementNS" of class "RDFXMLHandler":
rdflib/plugins/parsers/rdfxml.py:184: error: No overload variant of "get" of "AttributesImpl" matches argument types "Tuple[str, str]", "None"  [call-overload]
rdflib/plugins/parsers/rdfxml.py:184: note: Possible overload variants:
rdflib/plugins/parsers/rdfxml.py:184: note:     def get(self, name: str, alternative: None = ...) -> Optional[str]
rdflib/plugins/parsers/rdfxml.py:184: note:     def get(self, name: str, alternative: str) -> str
rdflib/plugins/parsers/rdfxml.py:201: error: No overload variant of "get" of "AttributesImpl" matches argument types "Tuple[str, str]", "None"  [call-overload]
rdflib/plugins/parsers/rdfxml.py:201: note: Possible overload variants:
rdflib/plugins/parsers/rdfxml.py:201: note:     def get(self, name: str, alternative: None = ...) -> Optional[str]
rdflib/plugins/parsers/rdfxml.py:201: note:     def get(self, name: str, alternative: str) -> str
rdflib/plugins/parsers/rdfxml.py: note: In member "convert" of class "RDFXMLHandler":
rdflib/plugins/parsers/rdfxml.py:280: error: Statement is unreachable  [unreachable]
rdflib/plugins/parsers/rdfxml.py: note: In member "literal_element_start" of class "RDFXMLHandler":
rdflib/plugins/parsers/rdfxml.py:593: error: Incompatible types in assignment (expression has type "str", variable has type "Tuple[str, str]")  [assignment]
rdflib/plugins/parsers/rdfxml.py: note: In member "parse" of class "RDFXMLParser":
rdflib/plugins/parsers/rdfxml.py:646: error: "ContentHandler" has no attribute "preserve_bnode_ids"  [attr-defined]
test/test_literal/test_literal.py:54: error: Untyped decorator makes function "clear_bindings" untyped  [misc]
test/test_literal/test_literal.py:96: error: Untyped decorator makes function "test_cant_pass_invalid_lang" untyped  [misc]
test/test_literal/test_literal.py:118: error: Untyped decorator makes function "test_ill_typed_literals" untyped  [misc]
test/test_literal/test_literal.py:172: error: Untyped decorator makes function "test_literal_addsub" untyped  [misc]
test/test_literal/test_literal.py:646: error: Untyped decorator makes function "test_numeric_literals" untyped  [misc]
test/test_literal/test_literal.py:833: error: Untyped decorator makes function "test_literal_construction_value_class" untyped  [misc]
test/test_literal/test_literal.py:944: error: Untyped decorator makes function "test_literal_construction" untyped  [misc]
test/test_literal/test_literal.py:1015: error: Untyped decorator makes function "test_global_normalize" untyped  [misc]
Found 38 errors in 11 files (checked 394 source files)
raboof commented 1 month ago

fixed two things in #2879, happy to fix more but it's not clear which ones were introduced by my changes.

ashleysommer commented 1 month ago

@raboof Thanks for addressing this. Looks like there were only two (not six) errors introduced in this PR that are affecting mypy. (the other 4 I saw were coming from my other testing branch). These are the two:

 poetry run python -m mypy --show-error-context --show-error-codes --junit-xml=test_reports/3.8-ubuntu-latest-mypy-junit.xml
  rdflib/tools/defined_namespace_creator.py: note: In function "make_dn_file":
  rdflib/tools/defined_namespace_creator.py:148: error: Argument 1 to "len" has incompatible type "Iterable[str]"; expected "Sized"  [arg-type]
  test/test_namespace/test_definednamespace_creator.py: note: In function "test_get_target_namespace_elements":
  test/test_namespace/test_definednamespace_creator.py:172: error: Statement is unreachable  [unreachable]
  Found 2 errors in 2 files (checked 398 source files)

It appears these are the two you've addressed in #2879