Skip to content

Commit b030315

Browse files
authored
Merge pull request github#3088 from tausbn/python-prepare-autoformatting
Python: Prepare for autoformatting.
2 parents f1ad0da + 57af7b8 commit b030315

33 files changed

+194
-193
lines changed

python/ql/src/Classes/MethodCallOrder.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ predicate multiple_calls_to_superclass_method(ClassObject self, FunctionObject m
2222
multiple_invocation_paths(top, i1, i2, multi) and
2323
top.runtime(self.declaredAttribute(name)) and
2424
self.getASuperType().declaredAttribute(name) = multi |
25-
/* Only called twice if called from different functions,
26-
* or if one call-site can reach the other */
25+
// Only called twice if called from different functions,
26+
// or if one call-site can reach the other.
2727
i1.getCall().getScope() != i2.getCall().getScope()
2828
or
2929
i1.getCall().strictlyReaches(i2.getCall())

python/ql/src/Expressions/CallArgs.qll

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ private Keyword not_keyword_only_arg(Call call, FunctionValue func) {
3939
}
4040

4141
/** Gets the count of arguments that are passed as positional parameters even if they
42-
* are named in the call.
43-
* This is the sum of the number of positional arguments, the number of elements in any explicit tuple passed as *arg
44-
* plus the number of keyword arguments that do not match keyword-only arguments (if the function does not take **kwargs).
42+
* are named in the call.
43+
* This is the sum of the number of positional arguments, the number of elements in any explicit tuple passed as *arg
44+
* plus the number of keyword arguments that do not match keyword-only arguments (if the function does not take **kwargs).
4545
*/
4646

4747
private int positional_arg_count_for_call_objectapi(Call call, Object callable) {
@@ -59,9 +59,9 @@ private int positional_arg_count_for_call_objectapi(Call call, Object callable)
5959
}
6060

6161
/** Gets the count of arguments that are passed as positional parameters even if they
62-
* are named in the call.
63-
* This is the sum of the number of positional arguments, the number of elements in any explicit tuple passed as *arg
64-
* plus the number of keyword arguments that do not match keyword-only arguments (if the function does not take **kwargs).
62+
* are named in the call.
63+
* This is the sum of the number of positional arguments, the number of elements in any explicit tuple passed as *arg
64+
* plus the number of keyword arguments that do not match keyword-only arguments (if the function does not take **kwargs).
6565
*/
6666

6767
private int positional_arg_count_for_call(Call call, Value callable) {
@@ -139,10 +139,9 @@ predicate too_few_args_objectapi(Call call, Object callable, int limit) {
139139
arg_count_objectapi(call) < limit and
140140
exists(FunctionObject func | func = get_function_or_initializer_objectapi(callable) |
141141
call = func.getAFunctionCall().getNode() and limit = func.minParameters() and
142-
/* The combination of misuse of `mox.Mox().StubOutWithMock()`
143-
* and a bug in mox's implementation of methods results in having to
144-
* pass 1 too few arguments to the mocked function.
145-
*/
142+
// The combination of misuse of `mox.Mox().StubOutWithMock()`
143+
// and a bug in mox's implementation of methods results in having to
144+
// pass 1 too few arguments to the mocked function.
146145
not (useOfMoxInModule(call.getEnclosingModule()) and func.isNormalMethod())
147146
or
148147
call = func.getAMethodCall().getNode() and limit = func.minParameters() - 1
@@ -160,10 +159,9 @@ predicate too_few_args(Call call, Value callable, int limit) {
160159
arg_count(call) < limit and
161160
exists(FunctionValue func | func = get_function_or_initializer(callable) |
162161
call = func.getACall().getNode() and limit = func.minParameters() and
163-
/* The combination of misuse of `mox.Mox().StubOutWithMock()`
164-
* and a bug in mox's implementation of methods results in having to
165-
* pass 1 too few arguments to the mocked function.
166-
*/
162+
// The combination of misuse of `mox.Mox().StubOutWithMock()`
163+
// and a bug in mox's implementation of methods results in having to
164+
// pass 1 too few arguments to the mocked function.
167165
not (useOfMoxInModule(call.getEnclosingModule()) and func.isNormalMethod())
168166
or
169167
call = func.getACall().getNode() and limit = func.minParameters() - 1

python/ql/src/Testing/Mox.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import python
22

3-
/** Whether `mox` or `.StubOutWithMock()` is used in thin module `m`.
4-
*/
3+
/** Whether `mox` or `.StubOutWithMock()` is used in thin module `m`. */
54
predicate useOfMoxInModule(Module m) {
65
exists(ModuleObject mox |
76
mox.getName() = "mox" or mox.getName() = "mox3.mox" |

python/ql/src/analysis/CrossProjectDefinitions.qll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ class Symbol extends TSymbol {
4848
)
4949
}
5050

51-
/** Finds the `AstNode` that this `Symbol` refers to.
52-
*/
51+
/** Finds the `AstNode` that this `Symbol` refers to. */
5352
AstNode find() {
5453
this = TModule(result)
5554
or
@@ -91,8 +90,7 @@ class Symbol extends TSymbol {
9190
)
9291
}
9392

94-
/** Gets the `Symbol` that is the named member of this `Symbol`.
95-
*/
93+
/** Gets the `Symbol` that is the named member of this `Symbol`. */
9694
Symbol getMember(string name) {
9795
result = TMember(this, name)
9896
}

python/ql/src/analysis/DefinitionTracking.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ private newtype TDefinition =
1010
a instanceof Expr or a instanceof Stmt or a instanceof Module
1111
}
1212

13-
/** A definition for the purposes of jump-to-definition.
14-
*/
13+
/** A definition for the purposes of jump-to-definition. */
1514
class Definition extends TLocalDefinition {
1615

1716

@@ -159,8 +158,7 @@ private predicate delete_defn(DeletionDefinition def, Definition defn) {
159158
none()
160159
}
161160

162-
/* Implicit "defn" of the names of submodules at the start of an `__init__.py` file.
163-
*/
161+
/* Implicit "defn" of the names of submodules at the start of an `__init__.py` file. */
164162
private predicate implicit_submodule_defn(ImplicitSubModuleDefinition def, Definition defn) {
165163
exists(PackageObject package, ModuleObject mod |
166164
package.getInitModule().getModule() = def.getDefiningNode().getScope() and
@@ -170,7 +168,9 @@ private predicate implicit_submodule_defn(ImplicitSubModuleDefinition def, Defin
170168

171169
}
172170

173-
/* Helper for scope_entry_value_transfer(...). Transfer of values from the callsite to the callee, for enclosing variables, but not arguments/parameters */
171+
/* Helper for scope_entry_value_transfer(...).
172+
* Transfer of values from the callsite to the callee, for enclosing variables, but not arguments/parameters
173+
*/
174174
private predicate scope_entry_value_transfer_at_callsite(EssaVariable pred_var, ScopeEntryDefinition succ_def) {
175175
exists(CallNode callsite, FunctionObject f |
176176
f.getACall() = callsite and
@@ -469,8 +469,8 @@ class NiceLocationExpr extends @py_expr {
469469
or
470470
this.(Name).getLocation().hasLocationInfo(f, bl, bc, el, ec)
471471
or
472-
/* Show xxx for `xxx` in `from xxx import y` or
473-
* for `import xxx` or for `import xxx as yyy`. */
472+
// Show xxx for `xxx` in `from xxx import y` or
473+
// for `import xxx` or for `import xxx as yyy`.
474474
this.(ImportExpr).getLocation().hasLocationInfo(f, bl, bc, el, ec)
475475
or
476476
/* Show y for `y` in `from xxx import y` */

python/ql/src/semmle/python/AstExtended.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ abstract class AstNode extends AstNode_ {
2424
}
2525

2626
/** Whether this syntactic element is artificial, that is it is generated
27-
* by the compiler and is not present in the source */
27+
* by the compiler and is not present in the source */
2828
predicate isArtificial() {
2929
none()
3030
}

python/ql/src/semmle/python/Class.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class ClassDef extends Assign {
9292
class Class extends Class_, Scope, AstNode {
9393

9494
/** Use getADecorator() instead of getDefinition().getADecorator()
95-
* Use getMetaClass() instead of getDefinition().getMetaClass()
95+
* Use getMetaClass() instead of getDefinition().getMetaClass()
9696
*/
9797
deprecated ClassExpr getDefinition() {
9898
result = this.getParent()

python/ql/src/semmle/python/Comparisons.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

22
import python
33

4-
/* A class representing the six comparison operators, ==, !=, <, <=, > and >=.
5-
* */
4+
/** A class representing the six comparison operators, ==, !=, <, <=, > and >=. */
65
class CompareOp extends int {
76

87
CompareOp() {

python/ql/src/semmle/python/Exprs.qll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ class Repr extends Repr_ {
356356
/* Constants */
357357

358358
/** A bytes constant, such as `b'ascii'`. Note that unadorned string constants such as
359-
`"hello"` are treated as Bytes for Python2, but Unicode for Python3. */
359+
* `"hello"` are treated as Bytes for Python2, but Unicode for Python3. */
360360
class Bytes extends StrConst {
361361

362362
/* syntax: b"hello" */
@@ -395,8 +395,7 @@ class Ellipsis extends Ellipsis_ {
395395
}
396396

397397
/** Immutable literal expressions (except tuples).
398-
* Consists of string (both unicode and byte) literals
399-
* and numeric literals.
398+
* Consists of string (both unicode and byte) literals and numeric literals.
400399
*/
401400
abstract class ImmutableLiteral extends Expr {
402401

@@ -433,8 +432,10 @@ class IntegerLiteral extends Num {
433432
not this instanceof FloatLiteral and not this instanceof ImaginaryLiteral
434433
}
435434

436-
/** Gets the (integer) value of this constant. Will not return a result if the value does not fit into
437-
a 32 bit signed value */
435+
/**
436+
* Gets the (integer) value of this constant. Will not return a result if the value does not fit into
437+
* a 32 bit signed value
438+
*/
438439
int getValue() {
439440
result = this.getN().toInt()
440441
}
@@ -540,16 +541,19 @@ class NegativeIntegerLiteral extends ImmutableLiteral, UnaryExpr {
540541
py_cobjectnames(result, "-" + this.getOperand().(IntegerLiteral).getN())
541542
}
542543

543-
/** Gets the (integer) value of this constant. Will not return a result if the value does not fit into
544-
a 32 bit signed value */
544+
/**
545+
* Gets the (integer) value of this constant. Will not return a result if the value does not fit into
546+
* a 32 bit signed value
547+
*/
545548
int getValue() {
546549
result = -(this.getOperand().(IntegerLiteral).getValue())
547550
}
548551

549552
}
550553

551554
/** A unicode string expression, such as `u"\u20ac"`. Note that unadorned string constants such as
552-
"hello" are treated as Bytes for Python2, but Unicode for Python3. */
555+
* "hello" are treated as Bytes for Python2, but Unicode for Python3.
556+
*/
553557
class Unicode extends StrConst {
554558

555559
/* syntax: "hello" */

python/ql/src/semmle/python/Files.qll

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ class Folder extends Container {
129129

130130
}
131131

132-
/** A container is an abstract representation of a file system object that can
133-
hold elements of interest. */
132+
/**
133+
* A container is an abstract representation of a file system object that can
134+
* hold elements of interest.
135+
*/
134136
abstract class Container extends @container {
135137

136138
Container getParent() {
@@ -473,8 +475,10 @@ class Line extends @py_line {
473475

474476
}
475477

476-
/** A syntax error. Note that if there is a syntax error in a module,
477-
much information about that module will be lost */
478+
/**
479+
* A syntax error. Note that if there is a syntax error in a module,
480+
* much information about that module will be lost
481+
*/
478482
class SyntaxError extends Location {
479483

480484
SyntaxError() {
@@ -492,8 +496,10 @@ class SyntaxError extends Location {
492496

493497
}
494498

495-
/** An encoding error. Note that if there is an encoding error in a module,
496-
much information about that module will be lost */
499+
/**
500+
* An encoding error. Note that if there is an encoding error in a module,
501+
* much information about that module will be lost
502+
*/
497503
class EncodingError extends SyntaxError {
498504

499505
EncodingError() {

0 commit comments

Comments
 (0)