Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Authors
* Shane Smiskol - https://github.com/sshane
* Andreas Rammhold - https://github.com/andir
* Nicholas Bunn - https://github.com/NicholasBunn
* Nathan McDougall - https://github.com/nathanjmcdougall
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ Changelog
=========

latest
----------------
------

* Deprecate the `NamespacePackageEncountered` exception.
* Improve contribution experience for Windows developers using Just.

3.14 (2025-12-10)
Expand Down
28 changes: 23 additions & 5 deletions src/grimp/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import warnings


def __getattr__(name: str):
if name == "NamespacePackageEncountered":
_NamespacePackageEncountered._warn_deprecated()
return _NamespacePackageEncountered
raise AttributeError


class GrimpException(Exception):
"""
Base exception for all custom Grimp exceptions to inherit.
Expand All @@ -16,14 +26,22 @@ class NoSuchContainer(GrimpException):
"""


class NamespacePackageEncountered(GrimpException):
class _NamespacePackageEncountered(GrimpException):
"""
Indicates that there was no __init__.py at the top level.

This indicates a namespace package (see PEP 420), which is not currently supported. More
typically this is just an oversight which can be fixed by adding the __init__.py file.
Deprecated.
"""

# https://github.com/python-grimp/grimp/issues/272
@staticmethod
def _warn_deprecated():
warnings.warn(
"NamespacePackageEncountered is deprecated; graphs can now be built from "
"namespace packages starting from Grimp 3.14. This exception will not be "
"raised by Grimp anymore, and will be removed in Grimp 3.16.",
DeprecationWarning,
stacklevel=2,
)


class NotATopLevelModule(GrimpException):
"""
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from grimp import exceptions


Expand Down Expand Up @@ -54,3 +56,9 @@ def test_different_texts_are_not_equal(self):
lineno=3,
text="something else wrong",
)


class TestNamespacePackageEncountered:
def test_deprecated_access(self):
with pytest.warns(DeprecationWarning):
exceptions.NamespacePackageEncountered