Skip to content

Feat: more configuration for format command#2048

Merged
tobymao merged 2 commits intoSQLMesh:mainfrom
z3z1ma:feat/format-kwargs
Jan 30, 2024
Merged

Feat: more configuration for format command#2048
tobymao merged 2 commits intoSQLMesh:mainfrom
z3z1ma:feat/format-kwargs

Conversation

@z3z1ma
Copy link
Copy Markdown
Contributor

@z3z1ma z3z1ma commented Jan 30, 2024

Not enough configurability. Expose very nice implementation in Generator to the benefit of all users while preserving existing behavior by default.

@eakmanrq
Copy link
Copy Markdown
Collaborator

@z3z1ma Can you also add these to the magic command?

https://github.com/TobikoData/sqlmesh/blob/main/sqlmesh/magics.py#L627

@z3z1ma
Copy link
Copy Markdown
Contributor Author

z3z1ma commented Jan 30, 2024

You bet! Done @eakmanrq

"""Format all SQL models."""
args = parse_argstring(self.format, line)
context.format(args.transpile, args.new_line)
context.format(**vars(args))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's vars?

Copy link
Copy Markdown
Contributor Author

@z3z1ma z3z1ma Jan 30, 2024

Choose a reason for hiding this comment

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

The arg parser returns a Namespace. vars accesses the __dict__ attribute basically. On namespaces, this is a well defined behavior and way to convert it to a dict.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@tobymao tobymao merged commit 3e90abd into SQLMesh:main Jan 30, 2024
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.

3 participants