Skip to content

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Apr 25, 2025

Description

This PR fixes a bug where the --language python flag is ignored when initializing a codebase in a monorepo with both TypeScript and Python code.

Problem

When a user explicitly specifies a language (e.g., --language python), the language detection logic still runs and overrides the user's choice in a monorepo context where there are more TypeScript files than Python files.

Solution

  1. Modified ProjectConfig.from_path() and ProjectConfig.from_repo_operator() to respect the explicitly provided language parameter and only run language detection if no language is specified.

  2. Improved the language detection in _determine_language_by_git_file_count() to properly respect the specified subfolder path when counting files.

  3. Fixed the language parameter handling in Codebase constructor to properly handle both string and enum values.

  4. Added unit tests to verify that:

    • Explicitly provided language is respected and not overridden by detection
    • Language detection respects the specified subfolder

Testing

Added unit tests in tests/unit/codegen/sdk/codebase/test_language_detection.py to verify the fixes.

Fixes #479


💻 View my workAbout Codegen

@codecov
Copy link

codecov bot commented Apr 25, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/codegen/sdk/codebase/config.py 66.66% 1 Missing ⚠️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

bug: codegen ignores language flag in monorepo with both TS/Python present

1 participant