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

convert contract to dict #7222

Merged
merged 15 commits into from
Mar 28, 2023
Merged

convert contract to dict #7222

merged 15 commits into from
Mar 28, 2023

Conversation

emmyoop
Copy link
Member

@emmyoop emmyoop commented Mar 24, 2023

resolves #7184

Description

Converts contract from a bool to it's own object

contract: bool = False
to

@dataclass
class Contract(dbtClassMixin, Replaceable):
    enforced: bool = False

Checklist

@cla-bot cla-bot bot added the cla:yes label Mar 24, 2023
@emmyoop emmyoop marked this pull request as ready for review March 27, 2023 13:18
@emmyoop emmyoop requested review from a team as code owners March 27, 2023 13:18
@emmyoop emmyoop changed the title Er/ct 2314 contract dict convert contract to dict Mar 27, 2023
Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

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

I have a question about the use of a dictionary here. In my PR (also up for review) I'm adding a "contract_checksum" as a separate field, but which I assume will go in this new contract "thing". Do we actually want it to be a dictionary or an object with fields, such as "enabled" and "checksum"? There are pros and cons for each...

Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

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

Looks good, except for the location of the Contract class.

@@ -87,6 +87,11 @@ class Docs(dbtClassMixin, Replaceable):
node_color: Optional[str] = None


@dataclass
class Contract(dbtClassMixin, Replaceable):
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't look like the Contract class is used by anything in unparsed.py, so it ought to go in nodes.py. We should limit what nodes.py uses from unparsed.py as much as possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

That creates circular imports with model_config. Instead of nodes.py I moved it into model_config.py. The only other thing defined in there is Hook but I think it still makes sense since it's not used in unparsed.py.

@emmyoop emmyoop merged commit ab496af into main Mar 28, 2023
@emmyoop emmyoop deleted the er/ct-2314-contract-dict branch March 28, 2023 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-2314] [Feature] Do we _have_ to call the boolean property contract?
3 participants