Python: Clean up comments in preparation for autoformat.

This commit is contained in:
Taus Brock-Nannestad
2019-09-27 13:03:27 +02:00
parent 25985e901b
commit 4341e88fc4

View File

@@ -20,7 +20,7 @@ predicate global_name_used(Module m, Variable name) {
u.getEnclosingModule() = m
)
or
/* A use of an undefined class local variable, will use the global variable */
// A use of an undefined class local variable, will use the global variable
exists(Name u, LocalVariable v |
u.uses(v) and
v.getId() = name.getId() and
@@ -33,10 +33,10 @@ predicate global_name_used(Module m, Variable name) {
predicate all_not_understood(Module m) {
exists(GlobalVariable a |
a.getId() = "__all__" and a.getScope() = m |
/* __all__ is not defined as a simple list */
// `__all__` is not defined as a simple list
not m.declaredInAll(_)
or
/* __all__ is modified */
// `__all__` is modified
exists(Call c | c.getFunc().(Attribute).getObject() = a.getALoad())
)
}
@@ -45,10 +45,9 @@ predicate imported_module_used_in_doctest(Import imp) {
exists(string modname |
imp.getAName().getAsname().(Name).getId() = modname
and
/* Look for doctests containing the patterns:
* >>> …name…
* ... …name…
*/
// Look for doctests containing the patterns:
// >>> …name…
// ... …name…
exists(StrConst doc |
doc.getEnclosingModule() = imp.getScope() and
doc.isDocString() and
@@ -62,9 +61,8 @@ predicate imported_module_used_in_typehint(Import imp) {
imp.getAName().getAsname().(Name).getId() = modname and
loc.getFile() = imp.getScope().(Module).getFile()
|
/* Look for typehints containing the patterns:
* # type: …name…
*/
// Look for type hints containing the patterns:
// # type: …name…
exists(Comment typehint |
loc = typehint.getLocation() and
typehint.getText().regexpMatch("# type:.*" + modname + ".*")
@@ -95,10 +93,10 @@ predicate unused_import(Import imp, Variable name) {
and
not global_name_used(imp.getScope(), name)
and
/* Imports in __init__.py are used to force module loading */
// Imports in `__init__.py` are used to force module loading
not imp.getEnclosingModule().isPackageInit()
and
/* Name may be imported for use in epytext documentation */
// Name may be imported for use in epytext documentation
not exists(Comment cmt |
cmt.getText().matches("%L{" + name.getId() + "}%") |
cmt.getLocation().getFile() = imp.getLocation().getFile()
@@ -106,16 +104,15 @@ predicate unused_import(Import imp, Variable name) {
and
not name_acceptable_for_unused_variable(name)
and
/* Assume that opaque `__all__` includes imported module */
// Assume that opaque `__all__` includes imported module
not all_not_understood(imp.getEnclosingModule())
and
not imported_module_used_in_doctest(imp)
and
not imported_module_used_in_typehint(imp)
and
/* Only consider import statements that actually point-to something (possibly an unknown module).
* If this is not the case, it's likely that the import statement never gets executed.
*/
// Only consider import statements that actually point-to something (possibly an unknown module).
// If this is not the case, it's likely that the import statement never gets executed.
imp.getAName().getValue().pointsTo(_)
}