Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
feb2745
Add alloy-js/python dependency
mauriciogardini Jul 30, 2025
1699ed1
Add python scaffolding
Jul 31, 2025
1aef5a6
Add starting test structure (#34)
mauriciogardini Jul 31, 2025
2983d23
Add Atom (#36)
mauriciogardini Aug 11, 2025
3c9f2f6
Add typing (#38)
mauriciogardini Aug 14, 2025
fd65b54
Unify test utils (#42)
mauriciogardini Aug 14, 2025
05a4664
Update Python emitter framework
mauriciogardini Sep 22, 2025
d671338
Add `EnumDeclaration` implementation (#46)
mauriciogardini Sep 30, 2025
383ba19
Add TypeDeclaration component (#51)
mauriciogardini Oct 21, 2025
7655157
Add FunctionDeclaration (#50)
mauriciogardini Oct 28, 2025
119df07
Add starting test structure (#34)
mauriciogardini Jul 31, 2025
5622006
Update Python emitter framework
mauriciogardini Sep 22, 2025
9446d70
Add models and interfaces (#45)
mauriciogardini Nov 10, 2025
66c2178
Fix build
mauriciogardini Nov 12, 2025
6083e8d
Fix name conversion
mauriciogardini Nov 14, 2025
ceffa04
Fix
mauriciogardini Nov 17, 2025
1fb2830
Fix problems identified on emitter
mauriciogardini Nov 17, 2025
84b999c
Update exports
mauriciogardini Nov 19, 2025
5771a91
Upgrade dependencies
mauriciogardini Nov 21, 2025
3d50bab
Change parameter handling
mauriciogardini Nov 24, 2025
a13ac34
Make interfaces to never generate dataclasses
mauriciogardini Nov 24, 2025
2378c9e
Change Interface rendering
mauriciogardini Nov 25, 2025
e43b2e2
Fix test
mauriciogardini Nov 25, 2025
abcc8ff
Add UnionVariant TypeExpression support
mauriciogardini Nov 26, 2025
05f69d3
Remove TODOs
mauriciogardini Nov 26, 2025
ad6dd7c
Add NumericValue interface
mauriciogardini Dec 8, 2025
b91080a
Update alloy/python
mauriciogardini Dec 9, 2025
668084a
Rebase
mauriciogardini Dec 15, 2025
87ef4a0
Rebase
mauriciogardini Dec 15, 2025
62a859e
Make templates behave as macros
mauriciogardini Dec 16, 2025
8df4a8f
Small fixes
mauriciogardini Dec 16, 2025
85f8314
Create components
mauriciogardini Dec 16, 2025
275c68b
Add subpath exports
mauriciogardini Dec 16, 2025
cc2787f
Remove manual overrides
mauriciogardini Dec 17, 2025
004c66b
Update lock files
mauriciogardini Dec 17, 2025
d43641a
Fix based on feedback
mauriciogardini Dec 18, 2025
8babfd1
Consolidate 2 types of TypeExpression into one
mauriciogardini Dec 18, 2025
3be08eb
Sync pnpm-lock.yaml with main
mauriciogardini Dec 19, 2025
5c76573
Chronus
mauriciogardini Dec 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .chronus/changes/feature-ef-python-2025-11-19-1-26-8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/emitter-framework"
---

Add Python Emitter Framework implementation
17 changes: 1 addition & 16 deletions packages/emitter-framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ No changes, version bump only.

- [#8823](https://github.com/microsoft/typespec/pull/8823) Upgrade dependencies


## 0.12.0

### Features
Expand All @@ -29,7 +28,6 @@ No changes, version bump only.

- [#8474](https://github.com/microsoft/typespec/pull/8474) Remove development exports from published package


## 0.11.0

### Features
Expand All @@ -53,15 +51,13 @@ No changes, version bump only.
- [#8302](https://github.com/microsoft/typespec/pull/8302) [c#] Avoid generating double '?' after property name when the property is nullable union and it's prop.optional is true in the meantime
- [#8362](https://github.com/microsoft/typespec/pull/8362) Upgrade alloy to 0.20


## 0.10.0

### Bump dependencies

- [#8050](https://github.com/microsoft/typespec/pull/8050) Upgrade alloy 0.19
- [#7978](https://github.com/microsoft/typespec/pull/7978) Upgrade dependencies


## 0.9.0

### Features
Expand All @@ -79,7 +75,6 @@ No changes, version bump only.

- [#7650](https://github.com/microsoft/typespec/pull/7650) Adds subpath export for csharp emitter-framework components


## 0.8.0

### Features
Expand All @@ -94,7 +89,6 @@ No changes, version bump only.

- [#7369](https://github.com/microsoft/typespec/pull/7369) Render discriminated unions correctly


## 0.7.1

### Bump dependencies
Expand All @@ -105,21 +99,19 @@ No changes, version bump only.

- [#7321](https://github.com/microsoft/typespec/pull/7321) Use wasm version of tree sitter for snippet extractor


## 0.7.0

### Bump dependencies

- [#7186](https://github.com/microsoft/typespec/pull/7186) Upgrade to alloy 15


## 0.6.0

### Features

- [#7017](https://github.com/microsoft/typespec/pull/7017) [TypeScript] Add various function-related components - FunctionType, FunctionExpression, ArrowFunction, and InterfaceMethod.
- [#6972](https://github.com/microsoft/typespec/pull/6972) Add support for rendering a Value Expression
- [#7018](https://github.com/microsoft/typespec/pull/7018) Adds the `TspContextProvider` and `useTsp()` hook for providing and accessing TypeSpec context and the Typekit APIs (e.g. `# Changelog - @typespec/emitter-framework). Adds a new `Output` component that accepts a TypeSpec `Program` and automatically wraps children components with the `TspContextProvider`.
- [#7018](https://github.com/microsoft/typespec/pull/7018) Adds the `TspContextProvider` and `useTsp()` hook for providing and accessing TypeSpec context and the Typekit APIs (e.g. `# Changelog - @typespec/emitter-framework). Adds a new `Output`component that accepts a TypeSpec`Program`and automatically wraps children components with the`TspContextProvider`.

### Bump dependencies

Expand All @@ -129,21 +121,18 @@ No changes, version bump only.

- [#6951](https://github.com/microsoft/typespec/pull/6951) InterfaceMember should use Alloy


## 0.5.0

### Features

- [#6875](https://github.com/microsoft/typespec/pull/6875) Upgrade to alloy 0.10.0


## 0.4.0

### Bump dependencies

- [#6595](https://github.com/microsoft/typespec/pull/6595) Upgrade dependencies


## 0.3.0

### Bump dependencies
Expand All @@ -155,12 +144,8 @@ No changes, version bump only.
- [#6178](https://github.com/microsoft/typespec/pull/6178) Improvements on the TestHarness
- [#6460](https://github.com/microsoft/typespec/pull/6460) Update dependency structure for EmitterFramework, HttpClient and JS Emitter




## 0.2.0

### Features

- [#5996](https://github.com/microsoft/typespec/pull/5996) Adding Emitter Framework and Http Client packages

9 changes: 9 additions & 0 deletions packages/emitter-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"./typescript": {
"import": "./dist/src/typescript/index.js"
},
"./python": {
"import": "./dist/src/python/index.js"
},
"./testing": {
"import": "./dist/src/testing/index.js"
}
Expand All @@ -48,6 +51,10 @@
"#typescript/*": {
"development": "./src/typescript/*",
"default": "./dist/src/typescript/*"
},
"#python/*": {
"development": "./src/python/*",
"default": "./dist/src/python/*"
}
},
"keywords": [],
Expand All @@ -57,12 +64,14 @@
"peerDependencies": {
"@alloy-js/core": "^0.22.0",
"@alloy-js/csharp": "^0.22.0",
"@alloy-js/python": "^0.3.0",
"@alloy-js/typescript": "^0.22.0",
"@typespec/compiler": "workspace:^"
},
"devDependencies": {
"@alloy-js/cli": "^0.22.0",
"@alloy-js/core": "^0.22.0",
"@alloy-js/python": "^0.3.0",
"@alloy-js/rollup-plugin": "^0.1.0",
"@alloy-js/typescript": "^0.22.0",
"@typespec/compiler": "workspace:^",
Expand Down
43 changes: 43 additions & 0 deletions packages/emitter-framework/src/python/builtins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { SymbolCreator } from "@alloy-js/core";
import { createModule } from "@alloy-js/python";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
type dummy = SymbolCreator;

export const abcModule = createModule({
name: "abc",
descriptor: {
".": ["ABC"],
},
});

export const datetimeModule = createModule({
name: "datetime",
descriptor: {
".": ["datetime", "date", "time", "timedelta", "timezone"],
},
});

export const decimalModule = createModule({
name: "decimal",
descriptor: {
".": ["Decimal"],
},
});

export const typingModule = createModule({
name: "typing",
descriptor: {
".": [
"Any",
"Callable",
"Generic",
"Literal",
"Never",
"Optional",
"Protocol",
"TypeAlias",
"TypeVar",
],
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Tester } from "#test/test-host.js";
import { d } from "@alloy-js/core/testing";
import { t } from "@typespec/compiler/testing";
import { expect, it } from "vitest";
import { getOutput } from "../../test-utils.js";
import { TypeExpression } from "../type-expression/type-expression.js";

it("maps array expression to Python list", async () => {
const { program, TestArray } = await Tester.compile(t.code`
alias ${t.type("TestArray")} = string[];
`);

expect(getOutput(program, [<TypeExpression type={TestArray} />])).toRenderTo(d`list[str]`);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { code } from "@alloy-js/core";
import type { Type } from "@typespec/compiler";
import { TypeExpression } from "../type-expression/type-expression.js";

export interface ArrayExpressionProps {
elementType: Type;
}

export function ArrayExpression({ elementType }: ArrayExpressionProps) {
return code`list[${(<TypeExpression type={elementType} />)}]`;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./array-expression.js";
Loading
Loading