-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(python): Handle Duplicative Import Names (#5377)
* Get it working * Optimize and simplify code * Address nits * Add util for generating python class names * Integrate and update tests * Update test * Use named interface for UniqueReferenceValue * Rename to getFullyQualifiedModulePath * Add test case
- Loading branch information
1 parent
a2aa8cf
commit 7687e8b
Showing
8 changed files
with
311 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { createPythonClassName } from "../../core/utils"; | ||
|
||
describe("Casing", () => { | ||
describe("createPythonClassName", () => { | ||
const testCases: [string, string][] = [ | ||
// Basic cases | ||
["hello world", "HelloWorld"], | ||
["simpleTestCase", "SimpleTestCase"], | ||
// Special characters | ||
["hello-world", "HelloWorld"], | ||
["$special#characters%", "SpecialCharacters"], | ||
// Numbers | ||
["123 invalid class name", "Class123InvalidClassName"], | ||
["mixed 123 cases", "Mixed123Cases"], | ||
// Underscores | ||
["_leading_underscores_", "LeadingUnderscores"], | ||
["trailing_underscores_", "TrailingUnderscores"], | ||
["_123numbers_starting", "Class123NumbersStarting"], | ||
// Empty and invalid input | ||
["", "Class"], | ||
["123", "Class123"], | ||
["_123_", "Class123"], | ||
// Complex cases | ||
["complex mix_of-DifferentCases", "ComplexMixOfDifferentCases"], | ||
["ALLCAPS input", "ALLCAPSInput"], // Preserve ALLCAPS as requested | ||
["PascalCaseAlready", "PascalCaseAlready"] | ||
]; | ||
|
||
it.each<[string, string]>(testCases)("should convert %s' to %s'", (input, expected) => { | ||
expect(createPythonClassName(input)).toBe(expected); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
export type ModulePath = string[] | Readonly<string[]>; | ||
|
||
export type AttrPath = string[] | Readonly<string[]>; | ||
|
||
export interface ImportedName { | ||
name: string; | ||
isAlias?: boolean; | ||
} |
Oops, something went wrong.