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

Another file's variable is not defined error #195

Open
xncbf opened this issue Dec 26, 2021 · 0 comments
Open

Another file's variable is not defined error #195

xncbf opened this issue Dec 26, 2021 · 0 comments
Labels
requires triage New issue that requires categorization

Comments

@xncbf
Copy link

xncbf commented Dec 26, 2021

ref: #14

If i use declared_attr in the upper mixin class, i get Name "Carrier" is not defined error.
Using import like below, which is not used anywhere, fixes the error, but this is not the way I want it to be.

# models.py
if TYPE_CHECKING:
  from module.to.carrier import Carrier

My code in mixin.py

@declarative_mixin
class DeliveryRefundPolicyMixin:
    @declared_attr
    def default_carrier(cls) -> Mapped["Carrier"]:
        return relationship("Carrier", primaryjoin="Carrier.id==%s.default_carrier_id" % cls.__name__)

models.py

class ProductBase(AbstractBase, DeliveryRefundPolicyMixin):
    __abstract__ = True

models.py not using Carrier anywhere but got not defined error in models.py

@xncbf xncbf added the requires triage New issue that requires categorization label Dec 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires triage New issue that requires categorization
Projects
None yet
Development

No branches or pull requests

1 participant