PythonNest / PyNest

PyNest is a Python framework built on top of FastAPI that follows the modular architecture of NestJS
https://pythonnest.github.io/PyNest
MIT License
643 stars 45 forks source link

Module Metadata not displaying EXPORTS correctly #56

Closed JEub closed 1 month ago

JEub commented 2 months ago

I think your Module decorator is not creating the EXPORT metadata correctly. I believe it should be setting the attribute with self.exports instead of imports.

class Module:
    def __init__(
        self,
        imports=None,
        controllers=None,
        providers=None,
        exports=None,
        is_global: bool = False,
    ):
        self.controllers = controllers or []
        self.providers = providers or []
        self.imports = imports or []
        self.exports = exports
        self.is_global = is_global

    def __call__(self, cls):
        setattr(cls, ModuleMetadata.CONTROLLERS, self.controllers)
        setattr(cls, ModuleMetadata.PROVIDER, self.providers)
        setattr(cls, ModuleMetadata.IMPORT, self.imports)
        setattr(cls, ModuleMetadata.EXPORTS, self.imports)  # <- This seems like it should be self.exports
        setattr(cls, "__is_module__", True)
        setattr(cls, "__is_global__", self.is_global)

        return cls
ItayTheDar commented 1 month ago

@JEub Hi! Sorry for the delay, not sure how I missed so an important issue. I can see that there is a mix in the keywords. the problem is that no functionality uses these exports, so there was no way to know that this is broken. Do you want to open a patch PR for that? this could be a real quick win

ItayTheDar commented 1 month ago

@JEub issue fixed in this commit - https://github.com/PythonNest/PyNest/pull/60/commits/69771ac01d26ff29c8da088ed3a2e9da36b85db1

Thanks again for raising this issue!