Skip to content

Commit ad46303

Browse files
committed
Python: Clarify comment about 'syntax:' comment and add ... to for and async for comments.
1 parent a256945 commit ad46303

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import python
33
/** Syntactic node (Class, Function, Module, Expr, Stmt or Comprehension) corresponding to a flow node */
44
abstract class AstNode extends AstNode_ {
55

6-
/* Special comment for documentation generation */
7-
/* syntax: */
6+
/* Special comment for documentation generation.
7+
* All subclasses of `AstNode` that represent concrete syntax should have
8+
* a comment of the form: */
9+
/* syntax: ... */
810

911
/** Gets the scope that this node occurs in */
1012
abstract Scope getScope();

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class Expr extends Expr_, AstNode {
131131
/** An attribute expression, such as `value.attr` */
132132
class Attribute extends Attribute_ {
133133

134-
/* Special comment for documentation generation */
135134
/* syntax: Expr.name */
136135

137136
override Expr getASubExpression() {
@@ -481,7 +480,6 @@ class FloatLiteral extends Num {
481480
class ImaginaryLiteral extends Num {
482481
private float value;
483482

484-
/* Special comment for documentation generation */
485483
/* syntax: 1.0j */
486484

487485
ImaginaryLiteral() {
@@ -541,7 +539,6 @@ class NegativeIntegerLiteral extends ImmutableLiteral, UnaryExpr {
541539
"hello" are treated as Bytes for Python2, but Unicode for Python3. */
542540
class Unicode extends StrConst {
543541

544-
/* Special comment for documentation generation */
545542
/* syntax: "hello" */
546543

547544
Unicode() {
@@ -572,7 +569,6 @@ class Unicode extends StrConst {
572569
/** A dictionary expression, such as `{'key':'value'}` */
573570
class Dict extends Dict_ {
574571

575-
/* Special comment for documentation generation */
576572
/* syntax: {Expr: Expr, ...} */
577573

578574
/** Gets the value of an item of this dict display */
@@ -600,7 +596,6 @@ class Dict extends Dict_ {
600596
/** A list expression, such as `[ 1, 3, 5, 7, 9 ]` */
601597
class List extends List_ {
602598

603-
/* Special comment for documentation generation */
604599
/* syntax: [Expr, ...] */
605600

606601
override Expr getASubExpression() {
@@ -612,7 +607,6 @@ class List extends List_ {
612607
/** A set expression such as `{ 1, 3, 5, 7, 9 }` */
613608
class Set extends Set_ {
614609

615-
/* Special comment for documentation generation */
616610
/* syntax: {Expr, ...} */
617611

618612
override Expr getASubExpression() {
@@ -749,7 +743,6 @@ class Slice extends Slice_ {
749743
/** A string constant. */
750744
class StrConst extends Str_, ImmutableLiteral {
751745

752-
/* Special comment for documentation generation */
753746
/* syntax: "hello" */
754747

755748
predicate isUnicode() {
@@ -837,7 +830,6 @@ abstract class BooleanLiteral extends NameConstant {
837830
/** The boolean named constant `True` */
838831
class True extends BooleanLiteral {
839832

840-
/* Special comment for documentation generation */
841833
/* syntax: True */
842834

843835
True() {
@@ -857,7 +849,6 @@ class True extends BooleanLiteral {
857849
/** The boolean named constant `False` */
858850
class False extends BooleanLiteral {
859851

860-
/* Special comment for documentation generation */
861852
/* syntax: False */
862853

863854
False() {
@@ -877,7 +868,6 @@ class False extends BooleanLiteral {
877868
/** `None` */
878869
class None extends NameConstant {
879870

880-
/* Special comment for documentation generation */
881871
/* syntax: None */
882872

883873
None() {
@@ -896,7 +886,6 @@ class None extends NameConstant {
896886
/** An await expression such as `await coro`. */
897887
class Await extends Await_ {
898888

899-
/* Special comment for documentation generation */
900889
/* syntax: await Expr */
901890

902891
override Expr getASubExpression() {

python/ql/src/semmle/python/Stmts.qll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ class Assign extends Assign_ {
9898
/** An assignment statement */
9999
class AssignStmt extends Assign {
100100

101-
/* Special comment for documentation generation */
102101
/* syntax: Expr, ... = Expr */
103102

104103
AssignStmt() {
@@ -281,7 +280,7 @@ class ExprStmt extends ExprStmt_ {
281280
/** A for statement, such as `for x in y: print(x)` */
282281
class For extends For_ {
283282

284-
/* syntax: for varname in Expr: */
283+
/* syntax: for varname in Expr: ... */
285284

286285
override Stmt getASubStatement() {
287286
result = this.getAStmt() or
@@ -569,7 +568,7 @@ class TemplateWrite extends TemplateWrite_ {
569568

570569
class AsyncFor extends For {
571570

572-
/* syntax: async for varname in Expr: */
571+
/* syntax: async for varname in Expr: ... */
573572

574573
AsyncFor() {
575574
this.isAsync()

0 commit comments

Comments
 (0)