Skip to content

Commit b419b5f

Browse files
committed
First pass at an explicit list of (non-)public API
1 parent 0c0c910 commit b419b5f

File tree

6 files changed

+41
-2
lines changed

6 files changed

+41
-2
lines changed

docs/changes.rst

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Changelog
33
=========
44

5+
v0.26.3
6+
-------
7+
8+
* Add some documentation on ``referencing`` public and non-public API.
9+
10+
511
v0.26.2
612
-------
713

docs/compatibility.rst

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=============
2+
Compatibility
3+
=============
4+
5+
``referencing`` is currently in beta so long as version numbers begin with a ``0``, meaning its public interface may change if issues are uncovered, though not typically without reason.
6+
Once it seems clear that the interfaces look correct (likely after ``referencing`` is in use for some period of time) versioning will move to `CalVer <https://calver.org/>`_ and interfaces will not change in backwards-incompatible ways without deprecation periods.
7+
8+
In the spirit of `having some explicit detail on Bowtie's public interfaces <regret:before-you-deprecate:document your public api>`, here is a non-exhaustive list of things which are *not* part of the ``referencing`` public interface, and therefore which may change without warning, even once no longer in beta:
9+
10+
* All commonly understood indicators of privacy in Python -- in particular, (sub)packages, modules and identifiers beginning with a single underscore.
11+
In the case of modules or packages, this includes *all* of their contents recursively, regardless of their naming.
12+
* All contents in the ``referencing.tests`` package unless explicitly indicated otherwise
13+
* The precise contents and wording of exception messages raised by any callable, private *or* public.
14+
* The precise contents of the ``__repr__`` of any type defined in the package.
15+
* The ability to *instantiate* exceptions defined in `referencing.exceptions`, with the sole exception of those explicitly indicating they are publicly instantiable (notably `referencing.exceptions.NoSuchResource`).
16+
* The instantiation of any type with no public identifier, even if instances of it are returned by other public API.
17+
E.g., `referencing._core.Resolver` is not publicly exposed, and it is not public API to instantiate it in ways other than by calling `referencing.Registry.resolver` or an equivalent.
18+
All of its public attributes are of course public, however.
19+
* Any identifiers in any modules which are imported from other modules.
20+
In other words, if ``referencing.foo`` imports ``bar`` from ``referencing.quux``, it is *not* public API to use ``referencing.foo.bar``; only ``referencing.quux.bar`` is public API.
21+
This does not apply to any objects exposed directly on the ``referencing`` package (e.g. `referencing.Resource`), which are indeed public.
22+
* Subclassing of any class defined throughout the package.
23+
Doing so is not supported for any object, and in general most types will raise exceptions to remind downstream users not to do so.
24+
25+
If any API usage may be questionable, feel free to open a discussion (or issue if appropriate) to clarify.

docs/conf.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ def entire_domain(host):
101101
intersphinx_mapping = {
102102
"hatch": ("https://hatch.pypa.io/latest/", None),
103103
"jsonschema-specifications": (
104-
"https://jsonschema-specifications.readthedocs.io/en/latest/",
104+
"https://jsonschema-specifications.readthedocs.io/en/stable/",
105105
None,
106106
),
107+
"regret": ("https://regret.readthedocs.io/en/stable/", None),
107108
"python": ("https://docs.python.org/", None),
108-
"setuptools": ("https://setuptools.pypa.io/en/latest/", None),
109+
"setuptools": ("https://setuptools.pypa.io/en/stable/", None),
109110
}
110111

111112
# -- extlinks --

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ In other words, a way for e.g. JSON Schema tooling to resolve the ``$ref`` keywo
1111
schema-packages
1212
api
1313
changes
14+
compatibility

docs/spelling-wordlist.txt

+3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ dereferenced
77
deserialized
88
discoverability
99
filesystem
10+
instantiable
11+
instantiation
1012
metaschemas
1113
referenceable
1214
resolvers
1315
runtime
1416
schemas
17+
subclassing
1518
submodules
1619
subresource
1720
subresources

referencing/exceptions.py

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
class NoSuchResource(KeyError):
1919
"""
2020
The given URI is not present in a registry.
21+
22+
Unlike most exceptions, this class *is* intended to be publicly
23+
instantiable and *is* part of the public API of the package.
2124
"""
2225

2326
ref: URI

0 commit comments

Comments
 (0)