diff --git a/packages/openapi-python/src/py-dsl/mixins/returns.ts b/packages/openapi-python/src/py-dsl/mixins/returns.ts index 91c976984..896e16ae8 100644 --- a/packages/openapi-python/src/py-dsl/mixins/returns.ts +++ b/packages/openapi-python/src/py-dsl/mixins/returns.ts @@ -1,8 +1,6 @@ import type { AnalysisContext, Node, NodeName } from '@hey-api/codegen-core'; -import { isSymbol } from '@hey-api/codegen-core'; import type { py } from '../../ts-python'; -import { IdPyDsl } from '../expr/identifier'; import type { BaseCtor, MixinCtor } from './types'; export interface ReturnsMethods extends Node { @@ -12,7 +10,7 @@ export interface ReturnsMethods extends Node { export function ReturnsMixin>(Base: TBase) { abstract class Returns extends Base { - protected _returns?: IdPyDsl | py.Expression; + protected _returns?: NodeName | py.Expression; override analyze(ctx: AnalysisContext): void { super.analyze(ctx); @@ -20,22 +18,12 @@ export function ReturnsMixin>(Base: } returns(type: NodeName | py.Expression): this { - if (typeof type === 'string' || isSymbol(type)) { - this._returns = new IdPyDsl(type); - } else { - this._returns = type as py.Expression; - } + this._returns = type; return this; } protected $returns(): py.Expression | undefined { - if (!this._returns) { - return; - } - if (this._returns instanceof IdPyDsl) { - return this._returns.toAst(); - } - return this._returns as py.Expression; + return this.$node(this._returns); } }