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

feat: get baml-fmt ready for beta #1278

Merged
merged 12 commits into from
Jan 4, 2025
Merged

feat: get baml-fmt ready for beta #1278

merged 12 commits into from
Jan 4, 2025

Conversation

sxlijin
Copy link
Collaborator

@sxlijin sxlijin commented Dec 31, 2024

baml-cli fmt is now in a state where I feel reasonably comfortable advertising it for beta use.

It's relatively limited in scope: I'm pretty sure class is the only thing it formats well; enum and function still need work.

But we now have support for:

  • preserving newlines
  • comments do not get reflowed in weird ways
  • baml-format: ignore disables the formatter

Important

Stabilizes baml-cli fmt for beta use, focusing on class formatting, preserving newlines and comments, and adds a directive to ignore formatting.

  • Behavior:
    • Stabilizes baml-cli fmt for beta use, focusing on formatting class structures.
    • Preserves newlines and comments; introduces baml-format: ignore directive to skip formatting.
  • Dependencies:
    • Updates pretty_assertions to 1.4.1 and adds regex in Cargo.toml.
  • Code Changes:
    • Refactors formatter/mod.rs to handle newlines and comments better.
    • Adds tests.rs for testing formatting behavior.
  • Documentation:
    • Adds fmt.mdx to document baml-cli fmt usage and limitations.

This description was created by Ellipsis for 179976a. It will automatically update as commits are pushed.

Copy link

vercel bot commented Dec 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
baml ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 4, 2025 2:18am

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 31de81f in 1 minute and 29 seconds

More details
  • Looked at 603 lines of code in 14 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. tools/build:169
  • Draft comment:
    Unresolved merge conflict markers detected. Please resolve the conflict by choosing the correct code block.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_6OQ42IE75keQk5to


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -17,7 +17,13 @@ $ pnpm add @boundaryml/baml
// biome-ignore format: autogenerated code
import { BamlRuntime, FunctionResult, BamlCtxManager, BamlSyncStream, Image, ClientRegistry, createBamlValidationError, BamlValidationError } from "@boundaryml/baml"
import { Checked, Check } from "./types"
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Unresolved merge conflict markers detected. Please resolve the conflict by choosing the correct code block.

@@ -50,7 +50,13 @@ export default class TypeBuilder {
constructor() {
this.tb = new _TypeBuilder({
classes: new Set([
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Unresolved merge conflict markers detected. Please resolve the conflict by choosing the correct code block.

@sxlijin sxlijin changed the title feat: teach formatter to preserve newlines in comments WIP[due to panic]: teach formatter to preserve newlines in comments Dec 31, 2024
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on 74f192b in 23 seconds

More details
  • Looked at 32 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. engine/cli/src/format.rs:35
  • Draft comment:
    Remove the commented-out line for BamlRuntime::parse_baml_src_path if it's not needed.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The commented-out line for BamlRuntime::parse_baml_src_path should be removed if it's not needed.

Workflow ID: wflow_CkZNWWBthKsNC0V4


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@sxlijin sxlijin changed the title WIP[due to panic]: teach formatter to preserve newlines in comments feat: make the formatter stable Jan 4, 2025
@sxlijin sxlijin changed the title feat: make the formatter stable feat: stabilize baml-fmt Jan 4, 2025
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on f5d40ca in 44 seconds

More details
  • Looked at 71 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. engine/baml-lib/schema-ast/src/formatter/tests.rs:14
  • Draft comment:
    Consider reformatting the formatted string and comparing it again to ensure idempotency of the formatter.
    assert_eq!(expected.unindent().trim_end(), formatted);

    let formatted = format_schema(
        &formatted.unindent().trim_end(),
        FormatOptions {
            indent_width: 2,
            fail_on_unhandled_rule: true,
        },
    )?;
    assert_eq!(formatted.unindent().trim_end(), formatted);
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The PR author deliberately removed the double-formatting check from assert_format_eq(). They likely had a good reason for this, and the idempotency property is still being tested in other ways throughout the test file. The comment is essentially asking to revert a deliberate change.
    Maybe the double-formatting check was important and removing it could let bugs slip through? Maybe there was a specific reason it was there in the first place?
    The test file shows that idempotency is still being verified in multiple test cases by explicitly formatting the expected output again. The removal of the double-check from assert_format_eq() was likely to simplify the helper function while maintaining the same test coverage.
    The comment should be deleted as it suggests reverting a deliberate change, and the property it's concerned about (formatter idempotency) is still being tested elsewhere in the file.

Workflow ID: wflow_xeo1hvtc00NbuIcE


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on bfc6041 in 15 seconds

More details
  • Looked at 32 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. fern/03-reference/baml-cli/fmt.mdx:25
  • Draft comment:
    Add a newline at the end of the file for better compatibility with various tools and to follow best practices.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The file is missing a newline at the end, which is a best practice for text files.

Workflow ID: wflow_nYTajkfaDL8VsN4p


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on 703dcc1 in 25 seconds

More details
  • Looked at 138 lines of code in 8 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. integ-tests/typescript/baml_client/sync_client.ts:20
  • Draft comment:
    The imports FormatterTest0, FormatterTest1, FormatterTest2, and FormatterTest3 are not used in this file. Consider removing them to clean up the code.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The import statement for FormatterTest0, FormatterTest1, FormatterTest2, and FormatterTest3 in the TypeScript file sync_client.ts seems unnecessary as these classes are not used in the file. Removing unused imports can help in reducing clutter and potential confusion.

Workflow ID: wflow_RGTBc9jbYj1Aa8g1


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@sxlijin sxlijin changed the title feat: stabilize baml-fmt feat: get baml-fmt ready for beta Jan 4, 2025
@sxlijin sxlijin enabled auto-merge January 4, 2025 02:10
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on 179976a in 1 minute and 3 seconds

More details
  • Looked at 2142 lines of code in 51 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. engine/language_client_python/pyproject.toml:3
  • Draft comment:
    The version bump to 0.71.1 is applied across multiple files. Ensure that this version change is consistent with the intended release and that all dependencies are correctly updated.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR description mentions that the baml-cli fmt is being stabilized for beta use, focusing on class formatting. However, the code changes include updates to version numbers across multiple files, which seems unrelated to the main feature described. This could indicate a version bump for a release, but it's not explicitly mentioned in the description.
2. engine/language_client_ruby/baml.gemspec:3
  • Draft comment:
    The version bump to 0.71.1 is applied across multiple files. Ensure that this version change is consistent with the intended release and that all dependencies are correctly updated.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR description mentions that the baml-cli fmt is being stabilized for beta use, focusing on class formatting. However, the code changes include updates to version numbers across multiple files, which seems unrelated to the main feature described. This could indicate a version bump for a release, but it's not explicitly mentioned in the description.
3. engine/language_client_typescript/package.json:3
  • Draft comment:
    The version bump to 0.71.1 is applied across multiple files. Ensure that this version change is consistent with the intended release and that all dependencies are correctly updated.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR description mentions that the baml-cli fmt is being stabilized for beta use, focusing on class formatting. However, the code changes include updates to version numbers across multiple files, which seems unrelated to the main feature described. This could indicate a version bump for a release, but it's not explicitly mentioned in the description.
4. typescript/vscode-ext/packages/package.json:5
  • Draft comment:
    The version bump to 0.71.1 is applied across multiple files. Ensure that this version change is consistent with the intended release and that all dependencies are correctly updated.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR description mentions that the baml-cli fmt is being stabilized for beta use, focusing on class formatting. However, the code changes include updates to version numbers across multiple files, which seems unrelated to the main feature described. This could indicate a version bump for a release, but it's not explicitly mentioned in the description.

Workflow ID: wflow_cGvtzv9De9gsqsXG


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@sxlijin sxlijin added this pull request to the merge queue Jan 4, 2025
Merged via the queue into canary with commit abb0958 Jan 4, 2025
10 of 11 checks passed
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