shacl2code 0.0.22__tar.gz → 0.0.23__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. {shacl2code-0.0.22 → shacl2code-0.0.23}/PKG-INFO +1 -1
  2. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/jsonschema.j2 +67 -51
  3. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/python.j2 +18 -12
  4. shacl2code-0.0.23/src/shacl2code/version.py +1 -0
  5. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/test_python.py +1 -0
  6. shacl2code-0.0.22/src/shacl2code/version.py +0 -1
  7. {shacl2code-0.0.22 → shacl2code-0.0.23}/.flake8 +0 -0
  8. {shacl2code-0.0.22 → shacl2code-0.0.23}/.github/workflows/coverage-generate.yaml +0 -0
  9. {shacl2code-0.0.22 → shacl2code-0.0.23}/.github/workflows/coverage-report.yaml +0 -0
  10. {shacl2code-0.0.22 → shacl2code-0.0.23}/.github/workflows/publish.yaml +0 -0
  11. {shacl2code-0.0.22 → shacl2code-0.0.23}/.github/workflows/scorecard.yml +0 -0
  12. {shacl2code-0.0.22 → shacl2code-0.0.23}/.github/workflows/test.yaml +0 -0
  13. {shacl2code-0.0.22 → shacl2code-0.0.23}/.gitignore +0 -0
  14. {shacl2code-0.0.22 → shacl2code-0.0.23}/LICENSE +0 -0
  15. {shacl2code-0.0.22 → shacl2code-0.0.23}/README.md +0 -0
  16. {shacl2code-0.0.22 → shacl2code-0.0.23}/SECURITY.md +0 -0
  17. {shacl2code-0.0.22 → shacl2code-0.0.23}/pyproject.toml +0 -0
  18. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/__init__.py +0 -0
  19. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/__main__.py +0 -0
  20. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/context.py +0 -0
  21. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/__init__.py +0 -0
  22. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/common.py +0 -0
  23. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/cpp.py +0 -0
  24. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/golang.py +0 -0
  25. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/jinja.py +0 -0
  26. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/jsonschema.py +0 -0
  27. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/lang.py +0 -0
  28. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/python.py +0 -0
  29. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/sources/cpp/json.hpp +0 -0
  30. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/Doxyfile.j2 +0 -0
  31. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/Makefile.j2 +0 -0
  32. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/api.hpp.j2 +0 -0
  33. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/datetime.cpp.j2 +0 -0
  34. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/datetime.hpp.j2 +0 -0
  35. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/decode.cpp.j2 +0 -0
  36. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/decode.hpp.j2 +0 -0
  37. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/encode.cpp.j2 +0 -0
  38. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/encode.hpp.j2 +0 -0
  39. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/errorhandler.cpp.j2 +0 -0
  40. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/errorhandler.hpp.j2 +0 -0
  41. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/exceptions.hpp.j2 +0 -0
  42. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/extensible.cpp.j2 +0 -0
  43. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/extensible.hpp.j2 +0 -0
  44. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/header.j2 +0 -0
  45. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/jsonld-header.j2 +0 -0
  46. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/jsonld-source.j2 +0 -0
  47. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/link.cpp.j2 +0 -0
  48. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/link.hpp.j2 +0 -0
  49. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/namedindividual.cpp.j2 +0 -0
  50. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/namedindividual.hpp.j2 +0 -0
  51. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/object.cpp.j2 +0 -0
  52. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/object.hpp.j2 +0 -0
  53. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/objectpath.cpp.j2 +0 -0
  54. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/objectpath.hpp.j2 +0 -0
  55. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/objectset.cpp.j2 +0 -0
  56. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/objectset.hpp.j2 +0 -0
  57. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/pkgconfig.pc.j2 +0 -0
  58. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/prop.hpp.j2 +0 -0
  59. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/property.cpp.j2 +0 -0
  60. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/property.hpp.j2 +0 -0
  61. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/propertyvalue.cpp.j2 +0 -0
  62. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/propertyvalue.hpp.j2 +0 -0
  63. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/ref.hpp.j2 +0 -0
  64. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/refproperty.cpp.j2 +0 -0
  65. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/refproperty.hpp.j2 +0 -0
  66. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/source.j2 +0 -0
  67. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/type.cpp.j2 +0 -0
  68. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/type.hpp.j2 +0 -0
  69. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/util.cpp.j2 +0 -0
  70. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/util.hpp.j2 +0 -0
  71. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/validate.j2 +0 -0
  72. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/cpp/walk.hpp.j2 +0 -0
  73. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/classes.go.j2 +0 -0
  74. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/decode.go.j2 +0 -0
  75. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/encode.go.j2 +0 -0
  76. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/errorhandler.go.j2 +0 -0
  77. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/errors.go.j2 +0 -0
  78. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/extensible.go.j2 +0 -0
  79. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/linkstate.go.j2 +0 -0
  80. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/listproperty.go.j2 +0 -0
  81. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/optional.go.j2 +0 -0
  82. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/path.go.j2 +0 -0
  83. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/property.go.j2 +0 -0
  84. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/ref.go.j2 +0 -0
  85. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/reflistproperty.go.j2 +0 -0
  86. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/refproperty.go.j2 +0 -0
  87. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/shaclobject.go.j2 +0 -0
  88. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/shaclobjectset.go.j2 +0 -0
  89. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/shacltype.go.j2 +0 -0
  90. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/util.go.j2 +0 -0
  91. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/lang/templates/golang/validator.go.j2 +0 -0
  92. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/main.py +0 -0
  93. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/model.py +0 -0
  94. {shacl2code-0.0.22 → shacl2code-0.0.23}/src/shacl2code/urlcontext.py +0 -0
  95. {shacl2code-0.0.22 → shacl2code-0.0.23}/testfixtures/testfixtures/__init__.py +0 -0
  96. {shacl2code-0.0.22 → shacl2code-0.0.23}/testfixtures/testfixtures/httpserver.py +0 -0
  97. {shacl2code-0.0.22 → shacl2code-0.0.23}/testfixtures/testfixtures/jsonvalidation.py +0 -0
  98. {shacl2code-0.0.22 → shacl2code-0.0.23}/testfixtures/testfixtures/timetests.py +0 -0
  99. {shacl2code-0.0.22 → shacl2code-0.0.23}/testfixtures/testfixtures/utils.py +0 -0
  100. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/conftest.py +0 -0
  101. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/abort.j2 +0 -0
  102. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/bad-id.j2 +0 -0
  103. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/bad-node-kind.ttl +0 -0
  104. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/bad-pattern-class.ttl +0 -0
  105. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/bad-pattern-integer.ttl +0 -0
  106. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/bad-prop-type.ttl +0 -0
  107. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/bad-reference.jsonld +0 -0
  108. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/context-url.j2 +0 -0
  109. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/context.j2 +0 -0
  110. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/links.json +0 -0
  111. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/missing-range.ttl +0 -0
  112. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/model/test-context.json +0 -0
  113. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/model/test.ttl +0 -0
  114. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/python/bad-object-type-inline.json +0 -0
  115. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/python/bad-object-type-ref-after.json +0 -0
  116. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/python/bad-object-type-ref-before.json +0 -0
  117. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/raw.j2 +0 -0
  118. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/data/roundtrip.json +0 -0
  119. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/test_cli.py +0 -0
  120. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/test_common_jinja.py +0 -0
  121. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/test_common_prefix.py +0 -0
  122. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/test_context.py +0 -0
  123. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/test_cpp.py +0 -0
  124. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/test_golang.py +0 -0
  125. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/test_jsonschema.py +0 -0
  126. {shacl2code-0.0.22 → shacl2code-0.0.23}/tests/test_model_source.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shacl2code
3
- Version: 0.0.22
3
+ Version: 0.0.23
4
4
  Summary: Convert SHACL model file to code bindings
5
5
  Project-URL: Homepage, https://github.com/JPEWdev/shacl2code
6
6
  Project-URL: Repository, https://github.com/JPEWdev/shacl2code.git
@@ -34,24 +34,28 @@
34
34
  "required": ["@context"],
35
35
  {%- endif %}
36
36
 
37
- "oneOf": [
38
- {
39
- "type": "object",
40
- "properties": {
41
- "@graph": {
42
- "description": "Top level container for JSON-LD objects",
43
- "type": "array",
44
- "items": {
45
- "type": "object",
46
- "$ref": "#/$defs/AnyClass",
47
- "unevaluatedProperties": false
48
- }
37
+ "if": {
38
+ "type": "object",
39
+ "required": ["@graph"]
40
+ },
41
+ "then": {
42
+ "type": "object",
43
+ "properties": {
44
+ "@graph": {
45
+ "description": "Top level container for JSON-LD objects",
46
+ "type": "array",
47
+ "items": {
48
+ "type": "object",
49
+ "$ref": "#/$defs/AnyClass",
50
+ "unevaluatedProperties": false
49
51
  }
50
- },
51
- "required": ["@graph"]
52
+ }
52
53
  },
53
- { "$ref": "#/$defs/AnyClass" }
54
- ],
54
+ "required": ["@graph"]
55
+ },
56
+ "else": {
57
+ "$ref": "#/$defs/AnyClass"
58
+ },
55
59
  "unevaluatedProperties": false,
56
60
 
57
61
  "$defs": {
@@ -61,39 +65,51 @@
61
65
  {#- @type tag #}
62
66
  {%- if not class.is_abstract or class.is_extensible %}
63
67
  "{{ varname(*class.clsname) }}": {
64
- "allOf": [
65
- {
66
- "type": "object",
67
- {%- if class.deprecated %}
68
- "deprecated": true,
69
- {%- endif %}
70
- {%- if class.is_extensible %}
71
- "unevaluatedProperties": true,
72
- {%- endif %}
73
- "properties": {
74
- "{{ class.id_property or "@id" }}": { "$ref": "#/$defs/{{ class.node_kind.split("#")[-1] }}" },
75
- "{{ context.compact_iri("@type") }}": {
76
- {#- Abstract Extensible classes are weird; any type _except_ the specific class type is allowed #}
77
- {%- if class.is_abstract and class.is_extensible %}
78
- "allOf": [
79
- { "$ref": "#/$defs/IRI" },
80
- { "not": { "const": "{{ context.compact_vocab(class._id) }}" } }
81
- ]
82
- {%- else %}
83
- "oneOf": [
84
- {%- if class.is_extensible %}
85
- { "$ref": "#/$defs/IRI" },
86
- {%- endif %}
87
- { "const": "{{ context.compact_vocab(class._id) }}" }
88
- ]
89
- {%- endif %}
90
- }
91
- }{%- if class.node_kind == SH.IRI %},
92
- "required": ["{{ class.id_property or "@id" }}"]
68
+ "if": {
69
+ "type": "object",
70
+ "properties": {
71
+ "{{ context.compact_iri("@type") }}": {
72
+ {#- Abstract Extensible classes are weird; any type _except_ the specific class type is allowed #}
73
+ {%- if class.is_abstract and class.is_extensible %}
74
+ "allOf": [
75
+ { "$ref": "#/$defs/IRI" },
76
+ { "not": { "const": "{{ context.compact_vocab(class._id) }}" } }
77
+ ]
78
+ {%- elif class.is_extensible %}
79
+ "anyOf": [
80
+ { "$ref": "#/$defs/IRI" },
81
+ { "const": "{{ context.compact_vocab(class._id) }}" }
82
+ ]
83
+ {%- else %}
84
+ "const": "{{ context.compact_vocab(class._id) }}"
93
85
  {%- endif %}
86
+ }
94
87
  },
95
- { "$ref": "#/$defs/{{ varname(*class.clsname) }}_props" }
96
- ]
88
+ "required": ["{{ context.compact_iri("@type") }}"]
89
+ },
90
+ "then": {
91
+ "allOf": [
92
+ {
93
+ "type": "object",
94
+ {%- if class.deprecated %}
95
+ "deprecated": true,
96
+ {%- endif %}
97
+ {%- if class.is_extensible %}
98
+ "unevaluatedProperties": true,
99
+ {%- endif %}
100
+ "properties": {
101
+ "{{ class.id_property or "@id" }}": { "$ref": "#/$defs/{{ class.node_kind.split("#")[-1] }}" },
102
+ "{{ context.compact_iri("@type") }}": { "type": "string" }
103
+ }{%- if class.node_kind == SH.IRI %},
104
+ "required": ["{{ class.id_property or "@id" }}"]
105
+ {%- endif %}
106
+ },
107
+ { "$ref": "#/$defs/{{ varname(*class.clsname) }}_props" }
108
+ ]
109
+ },
110
+ "else": {
111
+ "const": "Not a {{ varname(*class.clsname) }}"
112
+ }
97
113
  },
98
114
  {%- endif %}
99
115
  "{{ varname(*class.clsname) }}_derived": {
@@ -151,7 +167,7 @@
151
167
  "{{ context.compact_vocab(prop.path) }}": {
152
168
  {%- set prop_ref = "#/$defs/prop_" + varname(*class.clsname) + "_" + varname(prop.varname) %}
153
169
  {%- if is_list %}
154
- "oneOf": [
170
+ "anyOf": [
155
171
  {
156
172
  "type": "array",
157
173
  {%- if prop.max_count is not none %}
@@ -241,7 +257,7 @@
241
257
  {%- elif prop.datatype == "http://www.w3.org/2001/XMLSchema#boolean" %}
242
258
  "type": "boolean"
243
259
  {%- elif prop.datatype == "http://www.w3.org/2001/XMLSchema#decimal" %}
244
- "oneOf": [
260
+ "anyOf": [
245
261
  {
246
262
  "type": "number"
247
263
  },
@@ -266,7 +282,7 @@
266
282
  "pattern": "^_:.+"
267
283
  },
268
284
  "BlankNodeOrIRI": {
269
- "oneOf": [
285
+ "anyOf": [
270
286
  { "$ref": "#/$defs/IRI" },
271
287
  { "$ref": "#/$defs/BlankNode" }
272
288
  ]
@@ -278,7 +294,7 @@
278
294
  "type": "object",
279
295
  "properties": {
280
296
  "{{ context.compact_iri("@type") }}": {
281
- "oneOf": [
297
+ "anyOf": [
282
298
  { "$ref": "#/$defs/IRI" },
283
299
  {
284
300
  "enum": [
@@ -33,6 +33,7 @@ from typing import (
33
33
  Set,
34
34
  Tuple,
35
35
  Type,
36
+ TypeVar,
36
37
  Union,
37
38
  cast,
38
39
  )
@@ -540,10 +541,9 @@ class EnumProp(IRIProp):
540
541
  def validate(self, value) -> None:
541
542
  super().validate(value)
542
543
 
543
- valid_values = self.iri_values()
544
- if value not in valid_values:
544
+ if value not in self.iri_values():
545
545
  raise ValueError(
546
- f"'{value}' is not a valid value. Choose one of {' '.join(valid_values)}"
546
+ f"'{value}' is not a valid value. Choose one of {' '.join(self.iri_values())}"
547
547
  )
548
548
 
549
549
  def encode(self, encoder, value, state) -> None:
@@ -616,6 +616,7 @@ def register(
616
616
 
617
617
  register_lock = threading.Lock()
618
618
  NAMED_INDIVIDUALS: Set[str] = set()
619
+ ForeachT = TypeVar("ForeachT", bound="SHACLObject")
619
620
 
620
621
 
621
622
  @functools.total_ordering
@@ -861,7 +862,7 @@ class SHACLObject(object):
861
862
  ) as obj_s:
862
863
  self._encode_properties(obj_s, state)
863
864
 
864
- def _encode_properties(self, encoder, state):
865
+ def _encode_properties(self, encoder, state) -> None:
865
866
  for iri, prop, min_count, max_count, pyname, compact in self.__iter_props():
866
867
  value = self.__dict__["_obj_data"][iri]
867
868
  if prop.elide(value):
@@ -921,7 +922,9 @@ class SHACLObject(object):
921
922
 
922
923
  return obj
923
924
 
924
- def _decode_properties(self, decoder, objectset: Optional[SHACLObjectSet] = None):
925
+ def _decode_properties(
926
+ self, decoder, objectset: Optional[SHACLObjectSet] = None
927
+ ) -> None:
925
928
  for key in decoder.object_keys():
926
929
  if not self._decode_prop(decoder, key, objectset=objectset):
927
930
  raise KeyError(f"Unknown property '{key}'")
@@ -1019,7 +1022,9 @@ class SHACLExtensibleObject(SHACLObject):
1019
1022
  obj = cls(typ)
1020
1023
  return obj
1021
1024
 
1022
- def _decode_properties(self, decoder, objectset: Optional[SHACLObjectSet] = None):
1025
+ def _decode_properties(
1026
+ self, decoder, objectset: Optional[SHACLObjectSet] = None
1027
+ ) -> None:
1023
1028
  def decode_value(d):
1024
1029
  if not d.is_list():
1025
1030
  return d.read_value()
@@ -1042,7 +1047,7 @@ class SHACLExtensibleObject(SHACLObject):
1042
1047
  with decoder.read_property(key) as prop_d:
1043
1048
  self.__dict__["_obj_data"][key] = decode_value(prop_d)
1044
1049
 
1045
- def _encode_properties(self, encoder, state):
1050
+ def _encode_properties(self, encoder, state) -> None:
1046
1051
  super()._encode_properties(encoder, state)
1047
1052
  if self.CLOSED:
1048
1053
  return
@@ -1275,8 +1280,8 @@ class SHACLObjectSet(object):
1275
1280
  yield child
1276
1281
 
1277
1282
  def foreach_type(
1278
- self, typ: Union[str, SHACLObject], *, match_subclass: bool = True
1279
- ) -> Iterable[SHACLObject]:
1283
+ self, typ: Union[str, type[ForeachT]], *, match_subclass: bool = True
1284
+ ) -> Iterable[ForeachT]:
1280
1285
  """
1281
1286
  Iterate over each object of a specified type (or subclass there of)
1282
1287
 
@@ -1287,15 +1292,16 @@ class SHACLObjectSet(object):
1287
1292
  if not isinstance(typ, str):
1288
1293
  if not isinstance(typ, type) or not issubclass(typ, SHACLObject):
1289
1294
  raise TypeError(f"Type must be derived from SHACLObject, got {typ}")
1290
- typ = cast(SHACLObject, typ)
1291
- typ = typ._OBJ_TYPE
1295
+ # This intermediate step is necessary for pyrefly...
1296
+ typ_class: Type[SHACLObject] = typ
1297
+ typ = typ_class._OBJ_TYPE
1292
1298
 
1293
1299
  if typ not in self.obj_by_type:
1294
1300
  return
1295
1301
 
1296
1302
  for exact, o in self.obj_by_type[typ]:
1297
1303
  if match_subclass or exact:
1298
- yield o
1304
+ yield cast(ForeachT, o)
1299
1305
 
1300
1306
  def merge(self, *objectsets) -> "SHACLObjectSet":
1301
1307
  """
@@ -0,0 +1 @@
1
+ VERSION = "0.0.23"
@@ -154,6 +154,7 @@ class TestCheckType:
154
154
  check=True,
155
155
  )
156
156
 
157
+ @pytest.mark.xfail(reason="pyrefly is ignoring type annotations from rdflib")
157
158
  def test_pyrefly(self, tmp_path, args):
158
159
  """
159
160
  Pyrefly static type checking
@@ -1 +0,0 @@
1
- VERSION = "0.0.22"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes