1
- import { anyClassOrFunctionName , PythonType } from "./python" ;
1
+ import { simpleIdentifier , PythonType } from "./python" ;
2
2
3
3
/**
4
4
* The source of a type estimation.
@@ -58,7 +58,7 @@ export class TypeSearch {
58
58
return new VariableSearchResult ( typeName , EstimationSource . Value , valueAssignment ) ;
59
59
}
60
60
61
- match = new RegExp ( `^ *(${ anyClassOrFunctionName } )\\(?` ) . exec ( valueAssignment ) ;
61
+ match = new RegExp ( `^ *(${ simpleIdentifier } )\\(?` ) . exec ( valueAssignment ) ;
62
62
if ( ! match ) {
63
63
return null ;
64
64
}
@@ -152,7 +152,7 @@ export class TypeSearch {
152
152
* @returns The type hint of the found parameter or null.
153
153
*/
154
154
public static hintOfSimilarParam ( param : string , src : string ) : string | null {
155
- const m = new RegExp ( `^[ \t]*def ${ anyClassOrFunctionName } \\([^)]*\\b${ param } \\b: *([^), ]+)` , "m" ) . exec ( src ) ;
155
+ const m = new RegExp ( `^[ \t]*def ${ simpleIdentifier } \\([^)]*\\b${ param } \\b: *([^),\\s ]+)` , "m" ) . exec ( src ) ;
156
156
if ( m ) {
157
157
let hint = m [ 1 ] . trim ( ) ;
158
158
return hint ? hint : null ;
@@ -209,7 +209,7 @@ export class TypeSearch {
209
209
210
210
if ( s . length === 2 && module !== type ) {
211
211
match = new RegExp (
212
- `^[ \t]*import +${ module } |^[ \t]*from ${ anyClassOrFunctionName } import (${ module } )` , "m"
212
+ `^[ \t]*import +${ module } |^[ \t]*from ${ simpleIdentifier } import (${ module } )` , "m"
213
213
) . exec ( src ) ;
214
214
if ( match ) {
215
215
// Return 'Object.Type' for 'from x import Object'
@@ -227,9 +227,9 @@ export class TypeSearch {
227
227
*/
228
228
private static isImported ( value : string , src : string , checkForAsImports : boolean = true ) : boolean {
229
229
230
- let exp = `^[ \t]*(from +${ anyClassOrFunctionName } +import +${ value } ` ;
230
+ let exp = `^[ \t]*(from +${ simpleIdentifier } +import +${ value } ` ;
231
231
if ( checkForAsImports ) {
232
- exp += `|from +${ anyClassOrFunctionName } +import +${ anyClassOrFunctionName } +as +${ value } ` ;
232
+ exp += `|from +${ simpleIdentifier } +import +${ simpleIdentifier } +as +${ value } ` ;
233
233
}
234
234
exp += ")" ;
235
235
return new RegExp ( exp , "m" ) . test ( src ) ;
0 commit comments