Skip to content

Conversation

@saltenasl
Copy link
Contributor

@saltenasl saltenasl commented Jan 14, 2026

Summary by CodeRabbit

  • New Features
    • Format detection now recognizes Jupyter, Deepnote, Marimo, Percent, and Quarto formats and is exposed via the package API.
  • Tests
    • Added comprehensive tests covering format detection, edge cases, and error handling.
  • Chores
    • Package version bumped to 2.1.0.

✏️ Tip: You can customize this high-level summary in your review settings.

@saltenasl saltenasl requested a review from a team as a code owner January 14, 2026 03:49
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

📝 Walkthrough

Walkthrough

This pull request adds a new format detection module exporting detectFormat() and NotebookFormat (jupyter, deepnote, marimo, percent, quarto). It implements isMarimoContent and isPercentContent to identify formats in .py files while avoiding markers inside triple-quoted strings, and moves CLI usage to these central helpers. Tests cover content- and extension-based detection and error cases. The package version for @deepnote/convert is bumped from 2.0.0 to 2.1.0.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: exporting detectFormat and NotebookFormat from the convert package.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.



📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ec1fd5d and 10a56ee.

📒 Files selected for processing (1)
  • packages/convert/src/format-detection.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Place test files next to source files with .test.ts or .test.tsx extension
Use strict type checking in TypeScript files
Prefer type safety over convenience in TypeScript
Use const for immutable values
Avoid any types - use proper type definitions
Follow Biome's rules (configured in biome.json)
Use literal keys instead of bracket notation when possible
Prefer single quotes for strings (except when avoiding escapes)
Keep code clean and readable following Biome standards

Files:

  • packages/convert/src/format-detection.ts
🔇 Additional comments (4)
packages/convert/src/format-detection.ts (4)

1-1: LGTM!

Clean type definition.


7-11: Triple-quote heuristic has edge cases.

The exclusion regex ^\s*['"]{3}[\s\S]*?import marimo will false-negative when the marker appears after a closed triple-quote block, e.g.:

'''docstring'''
import marimo

The non-greedy match finds '''...import marimo, causing rejection.

If this is acceptable for your use cases, consider adding a comment noting the limitation.


14-19: Consistent with isMarimoContent.

Same triple-quote heuristic applies—same edge case limitations noted above.


25-42: LGTM!

Clear control flow. Marimo takes precedence over percent for ambiguous content—seems intentional.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.57%. Comparing base (e1df576) to head (10a56ee).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #210      +/-   ##
==========================================
+ Coverage   91.52%   91.57%   +0.04%     
==========================================
  Files          40       41       +1     
  Lines        2029     2041      +12     
  Branches      623      630       +7     
==========================================
+ Hits         1857     1869      +12     
  Misses        172      172              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/convert/src/cli.ts (1)

143-159: Potential DRY opportunity.

This logic mirrors detectFormat. Could delegate to it and catch its errors for custom messaging. Optional since current approach is clear.

🤖 Fix all issues with AI agents
In `@packages/convert/src/format-detection.test.ts`:
- Around line 112-147: Add a test case to the existing "Python file detection"
suite that verifies precedence when both markers exist: call
detectFormat('file.py', content) where content includes both a Marimo marker
(e.g., import marimo or `@app.cell`) and a percent marker (# %%), and assert the
result is 'marimo' to document that detectFormat prefers Marimo over percent;
add the test named like "prefers Marimo when both formats are present" alongside
the other .py tests.

In `@packages/convert/src/format-detection.ts`:
- Line 26: The variable named ext is misleading because it contains the full
lowercase filename rather than an extension; rename ext to a clearer identifier
like lowerFilename (or lowercasedFilename) wherever it is declared and used in
format-detection.ts (the const ext = filename.toLowerCase() line and all
subsequent references) and ensure any logic that actually extracts the extension
uses a separate, correctly named variable (e.g., ext =
path.extname(lowerFilename) or similar).
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e1df576 and 2aa153a.

📒 Files selected for processing (5)
  • packages/blocks/package.json
  • packages/convert/src/cli.ts
  • packages/convert/src/format-detection.test.ts
  • packages/convert/src/format-detection.ts
  • packages/convert/src/index.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Place test files next to source files with .test.ts or .test.tsx extension
Use strict type checking in TypeScript files
Prefer type safety over convenience in TypeScript
Use const for immutable values
Avoid any types - use proper type definitions
Follow Biome's rules (configured in biome.json)
Use literal keys instead of bracket notation when possible
Prefer single quotes for strings (except when avoiding escapes)
Keep code clean and readable following Biome standards

Files:

  • packages/convert/src/index.ts
  • packages/convert/src/cli.ts
  • packages/convert/src/format-detection.ts
  • packages/convert/src/format-detection.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.test.{ts,tsx}: Use Vitest as the testing framework
Follow existing test patterns in the codebase (see packages/blocks/src/blocks/*.test.ts)
Test edge cases, error handling, and special characters

Files:

  • packages/convert/src/format-detection.test.ts
🧬 Code graph analysis (1)
packages/convert/src/format-detection.test.ts (2)
packages/convert/src/format-detection.ts (3)
  • isMarimoContent (4-12)
  • isPercentContent (15-19)
  • detectFormat (25-42)
packages/convert/src/index.ts (1)
  • detectFormat (43-43)
🔇 Additional comments (5)
packages/blocks/package.json (1)

3-3: Unrelated version bump?

This bumps @deepnote/blocks but the PR changes are in @deepnote/convert. Verify this is intentional.

packages/convert/src/format-detection.ts (1)

1-42: Clean module design.

Well-structured with clear separation of concerns. The regex heuristics for string exclusion are documented and reasonable for the use case.

packages/convert/src/format-detection.test.ts (1)

1-156: Solid test coverage.

Clear structure, good edge cases for string literals. Tests align with implementation behavior.

packages/convert/src/cli.ts (1)

16-16: Good extraction.

Centralizes format detection logic. Direct import from ./format-detection avoids potential circular dependency through index.

packages/convert/src/index.ts (1)

40-43: Appropriate public API.

Exports only detectFormat and NotebookFormat. If consumers need isMarimoContent/isPercentContent directly, consider exporting them too.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@saltenasl saltenasl merged commit e457524 into main Jan 14, 2026
20 checks passed
@saltenasl saltenasl deleted the ls/convert-export-file-detection-logic branch January 14, 2026 04:04
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