Skip to content

Commit

Permalink
chore(python): Rename from attrPath to attributes (#4959)
Browse files Browse the repository at this point in the history
Rename from attrPath to attribute
  • Loading branch information
noanflaherty authored Oct 20, 2024
1 parent 2aa5fee commit a381d5f
Showing 4 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions generators/python-v2/codegen/src/ast/Reference.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ export declare namespace Reference {
/* The alias of the reference */
alias?: string;
/* The path to the attribute of the reference */
attrPath?: AttrPath;
attribute?: AttrPath;
}
}

@@ -27,15 +27,15 @@ export class Reference extends AstNode {
private modulePath: ModulePath;
private genericTypes: Type[];
private alias: string | undefined;
private attrPath: AttrPath;
private attribute: AttrPath;

constructor({ name, modulePath, genericTypes, alias, attrPath }: Reference.Args) {
constructor({ name, modulePath, genericTypes, alias, attribute }: Reference.Args) {
super();
this.name = name;
this.modulePath = modulePath ?? [];
this.genericTypes = genericTypes ?? [];
this.alias = alias;
this.attrPath = attrPath ?? [];
this.attribute = attribute ?? [];
}

public write(writer: Writer): void {
@@ -52,9 +52,9 @@ export class Reference extends AstNode {
writer.write("]");
}

if (this.attrPath.length > 0) {
if (this.attribute.length > 0) {
writer.write(".");
this.attrPath.forEach((attr, index) => {
this.attribute.forEach((attr, index) => {
if (index > 0) {
writer.write(".");
}
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ describe("PythonFile", () => {
const importedRef = python.reference({
modulePath: ["external_module"],
name: "ImportedClass",
attrPath: ["nested", "attribute"]
attribute: ["nested", "attribute"]
});

const field = python.field({
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ describe("Reference", () => {
const reference = python.reference({
name: "AttrPathClass",
modulePath: ["module"],
attrPath: ["attr1", "attr2"]
attribute: ["attr1", "attr2"]
});
reference.write(writer);
expect(await writer.toStringFormatted()).toMatchSnapshot();
2 changes: 1 addition & 1 deletion generators/python-v2/codegen/src/ast/__test__/Type.test.ts
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ describe("Type", () => {
python.reference({
name: "MyClass",
modulePath: ["module"],
attrPath: ["attr1", "attr2"]
attribute: ["attr1", "attr2"]
})
);
referenceType.write(writer);

0 comments on commit a381d5f

Please sign in to comment.