Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop Decouple Issue #99 #100

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

dev0Guy
Copy link
Contributor

@dev0Guy dev0Guy commented Feb 1, 2025

User description

#99


Generated description

Below is a concise technical summary of the changes proposed in this PR:

Decouples the PyNest framework from FastAPI by introducing abstraction layers and protocols. Replaces direct FastAPI imports with custom protocol implementations, allowing for potential future support of different web frameworks. Modifies core classes and decorators to work with these new abstractions. Introduces new modules in the nest.engine.proto package to define protocol interfaces for App, Router, and Route.

TopicDetails
Core Refactoring Refactors core classes and decorators to use the new abstraction layer
Modified files (7)
  • nest/core/pynest_factory.py
  • nest/core/cli_factory.py
  • nest/common/route_resolver.py
  • tests/test_core/__init__.py
  • nest/core/decorators/controller.py
  • nest/core/pynest_application.py
  • nest/core/decorators/class_based_view.py
Latest Contributors(2)
UserCommitDate
itay.dar@lemonade.comMigrate-pynest-to-poet...December 20, 2024
amirm.lavasani@gmail.comAdd-HTTP-Status-Code-F...June 24, 2024
Abstraction Layer Introduces protocol-based abstractions for App, Router, and Route to decouple from FastAPI
Modified files (6)
  • nest/engine/proto/__init__.py
  • nest/engine/proto/route.py
  • nest/engine/types.py
  • nest/engine/proto/app.py
  • nest/engine/fastapi/__init__.py
  • nest/engine/proto/router.py
Latest Contributors(0)
UserCommitDate
This pull request is reviewed by Baz. Join @dev0Guy and the rest of your team on (Baz).

@@ -0,0 +1,3 @@
from typing import Callable, TypeAlias, Any
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Failed check: CLI Test / test (MySQLSync)
I’ve attached the relevant part of the log for your convenience:
ImportError: cannot import name 'TypeAlias' from 'typing' module in Python 3.9


Finding type: Log Error

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this comment has been addressed. The commit 417821f has modified the import statement in nest/engine/types.py to resolve the ImportError. The TypeAlias import has been moved from 'typing' to 'typing_extensions', which should fix the issue with Python 3.9 compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed using import from typing_extensions instead of typing.
Maybe should check version and decide according to the version

router = APIRouter(tags=[tag] if tag else None)
tags = [tag] if tag else None
# TODO: replace with factory
router: Router = FastAPIRouter(tags=tags)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to think of a way to remove router intilization.
Could be done by creating abs for controller and make instace for fastapi/others.

instead of

from nest.core.decrator import Controller
from nest.decrator.fastapi import Controller

@dev0Guy
Copy link
Contributor Author

dev0Guy commented Feb 4, 2025

Importent point is creating difference Controller for each framework. Where each one is implementing Controller protocol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant