Skip to content

Commit b5f6c0e

Browse files
committed
Follow-on to cuda.core AGENTS.md
1 parent 42eecda commit b5f6c0e

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

cuda_core/AGENTS.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,19 @@ Python or Cython type annotations should be included for all public APIs. Avoid
125125
the use of `Any` unless absolutely necessary. The argument and return types as
126126
defined in the docstrings should match the type annotations.
127127

128+
The use of `if typing.TYPE_CHECK:` blocks is often necessary to avoid import
129+
cycles. However, this can occasionally mask symbols used by Sphinx to make
130+
cross-references in the docs. If importing an object doesn't create a cycle, it
131+
should be imported outside of an `if typing.TYPE_CHECK:` block, even if it is
132+
only used in type annotations.
133+
128134
### Semantics
129135

130-
Designs involving manual resource management should be avoided. Where
131-
appropriate, provide context managers (implemented with `__enter__` and
132-
`__exit__`, not `contextlib.contextmanager`) or RAII using a `__del__` or
133-
`__dealloc__` method.
136+
APIs should exist for both manual resource management (such as `close()`) and
137+
automatic resource management, using context managers or destructors where
138+
appropriate. Context managers should be implemented with `__enter__` and
139+
`__exit__`, not `contextlib.contextmanager`. For destructors use `__dealloc__`
140+
where possible, otherwise `__del__`.
134141

135142
### Documentation
136143

0 commit comments

Comments
 (0)