Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

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

* Deprecate the `NamespacePackageEncountered` exception.

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():
Comment thread
nathanjmcdougall marked this conversation as resolved.
warnings.warn(
"NamespacePackageEncountered is deprecated; graphs can now be built from "
Comment thread
nathanjmcdougall marked this conversation as resolved.
"namespace packages starting from Grimp 3.14. This exception will not be "
"raised by Grimp anymore.",
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