Skip to content

Commit e64ee9f

Browse files
authored
Creation of an RDFLib Charter (#3178)
* folded type_hints into developers * tidied references to guides * tidied balnk lines * removed redundant docco * charter * changes due to @ajnelson-nist comments
1 parent 7a1023f commit e64ee9f

File tree

6 files changed

+147
-200
lines changed

6 files changed

+147
-200
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ abstracts = list(x for x in g.objects(semweb, dbpedia['abstract']) if x.language
170170

171171
See also [./examples](./examples)
172172

173-
174173
## Features
175174
The library contains parsers and serializers for RDF/XML, N3,
176175
NTriples, N-Quads, Turtle, TriX, JSON-LD, RDFa and Microdata.

docs/CONTRIBUTING.md

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,58 @@
1-
# RDFLib Contributing Guide
1+
# Contributing Guide
22

3-
Thank you for considering contributing to RDFLib. This project has no formal
4-
funding or full-time maintainers, and relies entirely on independent
5-
contributors to keep it alive and relevant.
3+
Thank you for considering contributing to RDFLib. Contributors should understand and agree with
4+
the RDFLib Charter, below.
5+
6+
## Charter
7+
8+
### Vision
9+
10+
The RDFLib community wishes to provide a free and open source toolkit for the manipulation
11+
of RDF data.
12+
13+
This provision is for the community and by the community with contributors giving
14+
their time and skills freely and asking for nothing in return, other than acknowledgements
15+
of them as contributors.
16+
17+
The toolkit is released for use under the [BSD 3-Clause License](https://opensource.org/license/bsd-3-clause)
18+
to be as permissible as possibly: users can do what they wish with the toolkit.
19+
20+
### Scope
21+
22+
The community implements what it perceives to be core RDF manipulation functions within the RDFLib main
23+
library. It also implements specifications related to RDF, such as the SPARQL Query Language,
24+
SHACL the Shapes Validation Language, RDFS and OWL reasoning and the parsing and
25+
serialisation of RDF file formats. Some of these related implementations are modules
26+
within RDFLib, others are stand-alone repositories within the RDFLib family. See <https://rdflib.dev>
27+
for a listing.
28+
29+
The community encourages implementers of other RDFLib-related libraries to communicate them to us.
30+
31+
### Membership
32+
33+
There are no restrictions on users of, and contributors to RDFLib, therefore there is no strict
34+
membership category. We ask only that contributors contribute according to the various technical
35+
protocols in the [Developers guide](./developers.md) and the [Documentation guide](./docs.md).
36+
37+
### Governance
38+
39+
RDFLib had been governed by an evolving set of core developers over its 20+ year lifetime. There are
40+
no strict rules as to who is or isn't a core developer and the recent practice for organisation has been
41+
for the most involved developers to contact the mailing list and recent contributors directly to discuss
42+
major releases and other issues.
43+
44+
If you would like to be involved in core development and/or governance, please just create an Issue in
45+
the issue tracker about this, or contact the most active developers and/or the mailing list.
646

747
## Ways to contribute
848

949
Some ways in which you can contribute to RDFLib are:
1050

51+
- Create Issues on our [Issue Tracker](https://github.com/RDFLib/rdflib/issues/)
52+
for things that don't work or for feature requests
1153
- Address open issues:
1254
[![GitHub issues](https://img.shields.io/github/issues/RDFLib/rdflib)](https://github.com/RDFLib/rdflib/issues)
55+
by creating Pull Requests
1356
- Fix
1457
[expected failure](https://docs.pytest.org/en/latest/how-to/skipping.html#xfail-mark-test-functions-as-expected-to-fail)
1558
tests: [![GitHub search query](https://img.shields.io/badge/GitHub-search-green)](https://github.com/search?q=xfail+repo%3ARDFLib%2Frdflib+path%3Atest%2F**.py&amp%3Btype=code&type=code)
@@ -43,15 +86,12 @@ Some ways in which you can contribute to RDFLib are:
4386
- Fix linting failures (see ruff settings in `pyproject.toml` and `#
4487
noqa:` directives in the codebase).
4588

46-
## Pull Requests
89+
## Technical contributions
4790

48-
Contributions that involve changes to the RDFLib repository have to be made with
49-
pull requests and should follow the [RDFLib developers guide](./developers.md).
91+
If you would like to make technical contributions to RDFLIb, the _main_ way to do
92+
this is via creating Pull Requests to fix bugs or add features.
5093

51-
For changes that add features or affect the public API of RDFLib, it is
52-
recommended to first open an issue to discuss the change before starting to work
53-
on it. That way you can get feedback on the design of the feature before
54-
spending time on it.
94+
Please read the [RDFLib developers guide](./developers.md) for this.
5595

5696
## Code of Conduct
5797

docs/developers.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,97 @@ devcontainer build .
315315
devcontainer open .
316316
```
317317

318+
## Type Hints
319+
320+
This document provides some details about the type hints for RDFLib. More information about type hints can be found [here](https://docs.python.org/3/library/typing.html)
321+
322+
### Rationale for Type Hints
323+
324+
Type hints are code annotations that describe the types of variables, function parameters and function return value types in a way that can be understood by humans, static type checkers like [mypy](http://mypy-lang.org/), code editors like VSCode, documentation generators like mkdocstring, and other tools.
325+
326+
Static type checkers can use type hints to detect certain classes of errors by inspection. Code editors and IDEs can use type hints to provide better auto-completion and documentation generators can use type hints to generate better documentation.
327+
328+
These capabilities make it easier to develop a defect-free RDFLib and they also make it easier for users of RDFLib who can now use static type checkers to detect type errors in code that uses RDFLib.
329+
330+
### Gradual Typing Process
331+
332+
Type hints are being added to RDFLib through a process called [gradual typing](https://en.wikipedia.org/wiki/Gradual_typing). This process involves adding type hints to some parts of RDFLib while leaving the rest without type hints. Gradual typing is being applied to many, long-lived, Python code bases.
333+
334+
This process is beneficial in that we can realize some of the benefits of type hints without requiring that the whole codebase have type hints.
335+
336+
### Intended Type Hints
337+
338+
The intent is to have type hints in place for all of RDFLib and to have these type hints be as accurate as possible.
339+
340+
The accuracy of type hints is determined by both the standards that RDFLib aims to conform to, like RDF 1.1, and the deliberate choices that are made when implementing RDFLib. For example, given that the RDF 1.1 specification stipulates that the subject of an RDF triple cannot be a literal, all functions that accept an *RDF term* to be used as the subject of a triple should have type hints which excludes values that are literals.
341+
342+
There may be cases where some functionality of RDFLib may work perfectly well with values of types that are excluded by the type hints, but if these additional types violate the relevant standards we will consider the correct type hints to be those that exclude values of these types.
343+
344+
### Public Type Aliases
345+
346+
In python, type hints are specified in annotations. Type hints are different from type aliases which are normal python variables that are not intended to provide runtime utility and are instead intended for use in static type checking.
347+
348+
For clarity, the following is an example of a function `foo` with type hints:
349+
350+
```python
351+
def foo(a: int) -> int:
352+
return a + 1
353+
```
354+
355+
In the function `foo`, the input variable `a` is indicated to be of type `int` and the function is indicated to return an `int`.
356+
357+
The following is an example of a type alias `Bar`:
358+
359+
```python
360+
Bar = tuple[int, str]
361+
```
362+
363+
RDFLib will provide public type aliases under the `rdflib.typing` package, for example, `rdflib.typing.Triple`, `rdflib.typing.Quad`. Type aliases in the rest of RDFLib should be private (i.e. being with an underscore).
364+
365+
### Versioning, Compatibility and Stability
366+
367+
RDFLib attempts to adhere to [semver 2.0](https://semver.org/spec/v2.0.0.html) which is concerned with the public API of software.
368+
369+
Ignoring type hints, the public API of RDFLib exists implicitly as a consequence of the code of RDFLib and the actual behaviour this entails, the relevant standards that RDFLib is trying to implement, and the documentation of RDFLib, with some interplay between all three of these. RDFLib's public API includes public type aliases, as these are normal python variables and not annotations.
370+
371+
Type hints attempt to formally document RDFLib's implicitly-defined public API in a machine-readable fashion as accurately and correctly as possible within the framework outline earlier in this document.
372+
373+
Type hints do not affect the runtime API or behaviour of RDFLib. In this way then, they are somewhat outside of the scope of semver, however, they still have an impact on the users of RDFLib, even if this impact is not at runtime, but during development. This necessitates some clarity as to what users of RDFLib should expect regarding type hints in RDFLib releases.
374+
375+
Changes to type hints can broadly be classified as follow:
376+
377+
**Type Declaration**
378+
Adding type hints to existing code that had no explicit type hints, for example, changing
379+
380+
```python
381+
def foo(val):
382+
return val + 1
383+
```
384+
385+
to
386+
387+
```python
388+
def foo(val: int) -> int:
389+
return val + 1
390+
```
391+
392+
**Type Refinement**
393+
Refining existing type hints to be narrower, for example, changing a type hint of `typing.Collection` to `typing.Sequence`.
394+
395+
**Type Corrections**
396+
Correcting existing type hints which contradict the behaviour of the code or relevant specifications, for example, changing `typing.Sequence` from `typing.Set`
397+
398+
Given semver version components `MAJOR.MINOR.PATCH`, RDFLib will attempt to constrain type hint changes as follow:
399+
400+
| Version Component | Type Declaration | Type Refinement | Type Corrections |
401+
|------------------|-----------------|----------------|-----------------|
402+
| MAJOR | YES | YES | YES |
403+
| MINOR | YES | YES | YES |
404+
| PATCH | NO | NO | YES |
405+
406+
!!! caution "Type Corrections"
407+
A caveat worth nothing here is that code that passed type validation on one version of RDFLib can fail type validation on a later version of RDFLib that only differs in `PATCH` version component. This is as a consequence of potential *Type Corrections*.
408+
318409
## Writing documentation
319410

320411
We use mkdocs for generating HTML docs, see [docs](docs.md).

docs/index.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ If you are familiar with RDF and are looking for details on how RDFLib handles i
5252
* [Persistence](persistence.md)
5353
* [Merging](merging.md)
5454
* [Changelog](changelog.md)
55+
* [Security Considerations](security_considerations.md)
5556
* [Upgrade 6 to 7](upgrade6to7.md)
5657
* [Upgrade 5 to 6](upgrade5to6.md)
5758
* [Upgrade 4 to 5](upgrade4to5.md)
58-
* [Security Considerations](security_considerations.md)
5959

6060
## Versioning
6161

@@ -67,14 +67,12 @@ Given a version number `MAJOR.MINOR.PATCH`, increment the:
6767
2. `MINOR` version when you add functionality in a backwards-compatible manner
6868
3. `PATCH` version when you make backwards-compatible bug fixes
6969

70-
## For developers
70+
## Contributing
7171

72-
* [Developers guide](developers.md)
73-
* [Documentation guide](docs.md)
74-
* [Contributing guide](CONTRIBUTING.md)
72+
* [Contribution guide and charter](CONTRIBUTING.md)
73+
* [Developers guide](developers.md)
74+
* [Documentation guide](docs.md)
7575
* [Code of Conduct](CODE_OF_CONDUCT.md)
76-
* [Persisting N3 Terms](persisting_n3_terms.md)
77-
* [Type Hints](type_hints.md)
7876
* [Decisions](decisions.md)
7977

8078
## Source Code

docs/persisting_n3_terms.md

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)