Skip to content

Commit

Permalink
style: apply automated linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
megalinter-bot committed Jan 24, 2024
1 parent 239d978 commit be488ef
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
isSdsBlockLambdaResult,
isSdsCall,
isSdsCallable,
isSdsClass, isSdsDeclaration,
isSdsClass,
isSdsDeclaration,
isSdsEnumVariant,
isSdsExpressionLambda,
isSdsExpressionStatement,
Expand Down Expand Up @@ -74,7 +75,8 @@ import {
import { isInStubFile, isStubFile } from '../helpers/fileExtensions.js';
import { IdManager } from '../helpers/idManager.js';
import {
getAbstractResults, getArguments,
getAbstractResults,
getArguments,
getAssignees,
getImportedDeclarations,
getImports,
Expand Down Expand Up @@ -239,15 +241,17 @@ export class SafeDsPythonGenerator {

let current: SdsDeclaration | undefined = node;
while (current) {
const currentName = isSdsModule(current) ? this.getPythonModuleOrDefault(current) : this.getPythonNameOrDefault(current);
const currentName = isSdsModule(current)
? this.getPythonModuleOrDefault(current)
: this.getPythonNameOrDefault(current);
if (currentName) {
segments.unshift(currentName);
}
current = getContainerOfType(current.$container, isSdsDeclaration);
}

return segments.join('.');
};
}

private formatGeneratedFileName(baseName: string): string {
return `gen_${this.sanitizeModuleNameForPython(baseName)}`;
Expand Down Expand Up @@ -836,7 +840,7 @@ export class SafeDsPythonGenerator {
private isMemoizableCall(expression: SdsCall): boolean {
const impurityReasons = this.purityComputer.getImpurityReasonsForExpression(expression);
// If the file is not known, the call is not memoizable
return !impurityReasons.some(reason => !(reason instanceof FileRead) || reason.path === undefined);
return !impurityReasons.some((reason) => !(reason instanceof FileRead) || reason.path === undefined);
}

private generateMemoizedCall(
Expand All @@ -850,11 +854,10 @@ export class SafeDsPythonGenerator {
const memoizedArgs = getParameters(this.nodeMapper.callToCallable(expression)).map(
(parameter) => this.nodeMapper.callToParameterValue(expression, parameter)!,
);
const containsOptionalArgs =
sortedArgs
.map((arg) => this.nodeMapper.argumentToParameter(arg))
.filter((param) => param)
.some((param) => Parameter.isOptional(param));
const containsOptionalArgs = sortedArgs
.map((arg) => this.nodeMapper.argumentToParameter(arg))
.filter((param) => param)
.some((param) => Parameter.isOptional(param));
const fullyQualifiedTargetName = this.generateFullyQualifiedFunctionName(expression);
return expandTracedToNode(
expression,
Expand Down Expand Up @@ -913,9 +916,7 @@ export class SafeDsPythonGenerator {
return hiddenParameters;
}

private generateFullyQualifiedFunctionName(
expression: SdsCall,
): string {
private generateFullyQualifiedFunctionName(expression: SdsCall): string {
const callable = this.nodeMapper.callToCallable(expression);
if (isSdsDeclaration(callable)) {
const fullyQualifiedReferenceName = this.getQualifiedNamePythonCompatible(callable);
Expand All @@ -924,7 +925,7 @@ export class SafeDsPythonGenerator {
}
}
/* c8 ignore next */
throw new Error("Callable of provided call does not exist or is not a declaration.");
throw new Error('Callable of provided call does not exist or is not a declaration.');
}

private getArgumentsMap(
Expand Down Expand Up @@ -1016,9 +1017,9 @@ export class SafeDsPythonGenerator {
const targetModule = <SdsModule>findRootNode(declaration);
if (currentModule !== targetModule && !isInStubFile(targetModule)) {
return {
importPath: `${
this.getPythonModuleOrDefault(targetModule)
}.${this.formatGeneratedFileName(this.getModuleFileBaseName(targetModule))}`,
importPath: `${this.getPythonModuleOrDefault(targetModule)}.${this.formatGeneratedFileName(
this.getModuleFileBaseName(targetModule),
)}`,
declarationName: this.getPythonNameOrDefault(declaration),
};
}
Expand Down

0 comments on commit be488ef

Please sign in to comment.