Explicit export is not defined¶
ID: py/undefined-exportKind: problemSecurity severity: Severity: errorPrecision: highTags: - quality - reliability - correctnessQuery suites: - python-security-and-quality.qls
Click to see the query in the CodeQL repository
When a module is imported usingimport*, all attributes listed in__all__ are imported. If__all__ includes attributes that are not defined in the module then an exception is triggered. This usually indicates a typographic error in the attributes in__all__ or in the name of the object.
Recommendation¶
Correct any typographic errors, either in the name of the object or in the string in__all__. If there are no typographic errors, either delete the name from__all__ or add the object to the module.
Example¶
In the example, the function namespam has been misspelled in the__all__ list. This will result inspamm being highlighted as an undefined export. Correcting the spelling will fix the defect.
__all__=['spamm','troll','paywall']defspam():return'Spam'deftroll():return'Troll'defpaywall():return'Pay wall'
References¶
Python Language Reference:The import statement.
Python Tutorial:Importing * from a Package.