New feature: view and validate brick interfaces #424
DavidVujic
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Introducing a new feature: view and validate brick interfaces.
The feature is added to the
poly deps --brickcommand.Using a new option,
--interface, will display the public interface of a specific brick. Also, it will highlight if there are any usages that bypasses the public interface. It is reported as information, and will not exit with a failed code. The motivation for this is that the Polylith tool will not stop you if it is valid Python. 😄Example usage:
Output:
With the addition:
In case there are usages outside of the interface boundary:
a sub-module (in this example "hello_world") that isn't part of the public interface was used:
What's a brick interface?
The way the Polylith tool identifies a brick interface is by analyzing the contents of the
__init__.pymodule. This feature will treat all imported things, all variables, classes and functions in the__init__.pymodule as part of the interface (unless marked as "private" using_). In addition, it will also check the contents of the__all__variable if existing in the module.This feature will make it possible to inspect how a brick is used across the Polylith workspace. With the notifications about usage outside of the interface boundaries, you will be able to identify any unexpected usages.
Future plans
Adding the interface validations as part of the
poly checkcommand, or introduce a new command. This is currently ongoing work.Demo
In this recording, the
messagebrick exposes functions via the__init__.pymodule. There's another module in the brick folder, calledhello.py. When this is used from outside of the brick, it will be highlighted by the tool.This example is using the Polylith CLI with
uv, and it (of course) works the same way when usingPoetry.Beta Was this translation helpful? Give feedback.
All reactions