Python: Apply suggestions from code review

Co-authored-by: yoff <lerchedahl@gmail.com>
This commit is contained in:
Taus
2022-03-08 15:20:35 +01:00
committed by GitHub
parent 5a8ba6a7af
commit 063a8bbc43
12 changed files with 31 additions and 24 deletions

View File

@@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string {
abstract predicate hasActualResult(Location location, string element, string tag, string value); abstract predicate hasActualResult(Location location, string element, string tag, string value);
/** /**
* Holds similarly to `hasActualResult`, but returns results that do not require a matching annotation. * Holds if there is an optional result on the specified location.
*
* This is similar to `hasActualResult`, but returns results that do not require a matching annotation.
* A failure will still arise if there is an annotation that does not match any results, but not vice versa. * A failure will still arise if there is an annotation that does not match any results, but not vice versa.
* Override this predicate to specify optional results. * Override this predicate to specify optional results.
*/ */

View File

@@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string {
abstract predicate hasActualResult(Location location, string element, string tag, string value); abstract predicate hasActualResult(Location location, string element, string tag, string value);
/** /**
* Holds similarly to `hasActualResult`, but returns results that do not require a matching annotation. * Holds if there is an optional result on the specified location.
*
* This is similar to `hasActualResult`, but returns results that do not require a matching annotation.
* A failure will still arise if there is an annotation that does not match any results, but not vice versa. * A failure will still arise if there is an annotation that does not match any results, but not vice versa.
* Override this predicate to specify optional results. * Override this predicate to specify optional results.
*/ */

View File

@@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string {
abstract predicate hasActualResult(Location location, string element, string tag, string value); abstract predicate hasActualResult(Location location, string element, string tag, string value);
/** /**
* Holds similarly to `hasActualResult`, but returns results that do not require a matching annotation. * Holds if there is an optional result on the specified location.
*
* This is similar to `hasActualResult`, but returns results that do not require a matching annotation.
* A failure will still arise if there is an annotation that does not match any results, but not vice versa. * A failure will still arise if there is an annotation that does not match any results, but not vice versa.
* Override this predicate to specify optional results. * Override this predicate to specify optional results.
*/ */

View File

@@ -1619,7 +1619,7 @@ import IterableUnpacking
*/ */
module MatchUnpacking { module MatchUnpacking {
/** /**
* Holds when there is flow from the subject `nodeFrom` to the case `nodeTo` of a `match` statement. * Holds when there is flow from the subject `nodeFrom` to the (top-level) pattern `nodeTo` of a `match` statement.
* *
* The subject of a match flows to each top-level pattern * The subject of a match flows to each top-level pattern
* (a pattern directly under a `case` statement). * (a pattern directly under a `case` statement).

View File

@@ -15,7 +15,7 @@ private module Aiomysql {
private import semmle.python.internal.Awaited private import semmle.python.internal.Awaited
/** /**
* Gets the `ConnectionPool` that is created when the result of `aiomysql.create_pool()` is awaited. * Gets a `ConnectionPool` that is created when the result of `aiomysql.create_pool()` is awaited.
* See https://aiomysql.readthedocs.io/en/stable/pool.html * See https://aiomysql.readthedocs.io/en/stable/pool.html
*/ */
API::Node connectionPool() { API::Node connectionPool() {
@@ -23,7 +23,7 @@ private module Aiomysql {
} }
/** /**
* Gets the `Connection` that is created when * Gets a `Connection` that is created when
* - the result of `aiomysql.connect()` is awaited. * - the result of `aiomysql.connect()` is awaited.
* - the result of calling `aquire` on a `ConnectionPool` is awaited. * - the result of calling `aquire` on a `ConnectionPool` is awaited.
* See https://aiomysql.readthedocs.io/en/stable/connection.html#connection * See https://aiomysql.readthedocs.io/en/stable/connection.html#connection
@@ -35,7 +35,7 @@ private module Aiomysql {
} }
/** /**
* Gets the `Cursor` that is created when * Gets a `Cursor` that is created when
* - the result of calling `cursor` on a `ConnectionPool` is awaited. * - the result of calling `cursor` on a `ConnectionPool` is awaited.
* - the result of calling `cursor` on a `Connection` is awaited. * - the result of calling `cursor` on a `Connection` is awaited.
* See https://aiomysql.readthedocs.io/en/stable/cursors.html * See https://aiomysql.readthedocs.io/en/stable/cursors.html
@@ -85,7 +85,7 @@ private module Aiomysql {
} }
/** /**
* Gets the `Engine` that is created when the result of calling `aiomysql.sa.create_engine` is awaited. * Gets an `Engine` that is created when the result of calling `aiomysql.sa.create_engine` is awaited.
* See https://aiomysql.readthedocs.io/en/stable/sa.html#engine * See https://aiomysql.readthedocs.io/en/stable/sa.html#engine
*/ */
API::Node engine() { API::Node engine() {
@@ -98,7 +98,7 @@ private module Aiomysql {
} }
/** /**
* Gets the `SAConnection` that is created when the result of calling `aquire` on an `Engine` is awaited. * Gets an `SAConnection` that is created when the result of calling `aquire` on an `Engine` is awaited.
* See https://aiomysql.readthedocs.io/en/stable/sa.html#connection * See https://aiomysql.readthedocs.io/en/stable/sa.html#connection
*/ */
API::Node saConnection() { result = engine().getMember("acquire").getReturn().getAwaited() } API::Node saConnection() { result = engine().getMember("acquire").getReturn().getAwaited() }

View File

@@ -15,7 +15,7 @@ private module Aiopg {
private import semmle.python.internal.Awaited private import semmle.python.internal.Awaited
/** /**
* Gets the `ConnectionPool` that is created when the result of `aiopg.create_pool()` is awaited. * Gets a `ConnectionPool` that is created when the result of `aiopg.create_pool()` is awaited.
* See https://aiopg.readthedocs.io/en/stable/core.html#pool * See https://aiopg.readthedocs.io/en/stable/core.html#pool
*/ */
API::Node connectionPool() { API::Node connectionPool() {
@@ -23,7 +23,7 @@ private module Aiopg {
} }
/** /**
* Gets the `Connection` that is created when * Gets a `Connection` that is created when
* - the result of `aiopg.connect()` is awaited. * - the result of `aiopg.connect()` is awaited.
* - the result of calling `aquire` on a `ConnectionPool` is awaited. * - the result of calling `aquire` on a `ConnectionPool` is awaited.
* See https://aiopg.readthedocs.io/en/stable/core.html#connection * See https://aiopg.readthedocs.io/en/stable/core.html#connection
@@ -35,7 +35,7 @@ private module Aiopg {
} }
/** /**
* Gets the `Cursor` that is created when * Gets a `Cursor` that is created when
* - the result of calling `cursor` on a `ConnectionPool` is awaited. * - the result of calling `cursor` on a `ConnectionPool` is awaited.
* - the result of calling `cursor` on a `Connection` is awaited. * - the result of calling `cursor` on a `Connection` is awaited.
* See https://aiopg.readthedocs.io/en/stable/core.html#cursor * See https://aiopg.readthedocs.io/en/stable/core.html#cursor
@@ -85,7 +85,7 @@ private module Aiopg {
} }
/** /**
* Gets the `Engine` that is created when the result of calling `aiopg.sa.create_engine` is awaited. * Gets an `Engine` that is created when the result of calling `aiopg.sa.create_engine` is awaited.
* See https://aiopg.readthedocs.io/en/stable/sa.html#engine * See https://aiopg.readthedocs.io/en/stable/sa.html#engine
*/ */
API::Node engine() { API::Node engine() {
@@ -94,7 +94,7 @@ private module Aiopg {
} }
/** /**
* Gets the `SAConnection` that is created when the result of calling `aquire` on an `Engine` is awaited. * Gets an `SAConnection` that is created when the result of calling `aquire` on an `Engine` is awaited.
* See https://aiopg.readthedocs.io/en/stable/sa.html#connection * See https://aiopg.readthedocs.io/en/stable/sa.html#connection
*/ */
API::Node saConnection() { result = engine().getMember("acquire").getReturn().getAwaited() } API::Node saConnection() { result = engine().getMember("acquire").getReturn().getAwaited() }

View File

@@ -12,13 +12,13 @@ private import semmle.python.ApiGraphs
private module Asyncpg { private module Asyncpg {
private import semmle.python.internal.Awaited private import semmle.python.internal.Awaited
/** Gets the `ConnectionPool` that is created when the result of `asyncpg.create_pool()` is awaited. */ /** Gets a `ConnectionPool` that is created when the result of `asyncpg.create_pool()` is awaited. */
API::Node connectionPool() { API::Node connectionPool() {
result = API::moduleImport("asyncpg").getMember("create_pool").getReturn().getAwaited() result = API::moduleImport("asyncpg").getMember("create_pool").getReturn().getAwaited()
} }
/** /**
* Gets the `Connection` that is created when * Gets a `Connection` that is created when
* - the result of `asyncpg.connect()` is awaited. * - the result of `asyncpg.connect()` is awaited.
* - the result of calling `aquire` on a `ConnectionPool` is awaited. * - the result of calling `aquire` on a `ConnectionPool` is awaited.
*/ */

View File

@@ -447,7 +447,7 @@ ClassObject theBuiltinFunctionType() {
/** Gets the class of Python functions */ /** Gets the class of Python functions */
ClassObject thePyFunctionType() { result.asBuiltin() = Builtin::special("FunctionType") } ClassObject thePyFunctionType() { result.asBuiltin() = Builtin::special("FunctionType") }
/** Gets thGets the builtin class 'classmethod' */ /** Gets the builtin class 'classmethod' */
ClassObject theClassMethodType() { result.asBuiltin() = Builtin::special("ClassMethod") } ClassObject theClassMethodType() { result.asBuiltin() = Builtin::special("ClassMethod") }
/** Gets the builtin class 'staticmethod' */ /** Gets the builtin class 'staticmethod' */

View File

@@ -13,10 +13,7 @@
import python import python
/** /**
* Gets the name of a deprecated module (for a particular version of Python) and the name of a suggested * Holds if the module `name` was deprecated in Python version `major`.`minor`,
* replacement.
*
* The module `name` was deprecated in Python version `major`.`minor`,
* and module `instead` should be used instead (or `instead = "no replacement"`) * and module `instead` should be used instead (or `instead = "no replacement"`)
*/ */
predicate deprecated_module(string name, string instead, int major, int minor) { predicate deprecated_module(string name, string instead, int major, int minor) {

View File

@@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string {
abstract predicate hasActualResult(Location location, string element, string tag, string value); abstract predicate hasActualResult(Location location, string element, string tag, string value);
/** /**
* Holds similarly to `hasActualResult`, but returns results that do not require a matching annotation. * Holds if there is an optional result on the specified location.
*
* This is similar to `hasActualResult`, but returns results that do not require a matching annotation.
* A failure will still arise if there is an annotation that does not match any results, but not vice versa. * A failure will still arise if there is an annotation that does not match any results, but not vice versa.
* Override this predicate to specify optional results. * Override this predicate to specify optional results.
*/ */

View File

@@ -162,7 +162,7 @@ private Builtin traverse_qualname(Builtin parent, string qualname) {
} }
/** /**
* Arecorded call where we can identify both the `call` and the `callee` uniquely. * A recorded call where we can identify both the `call` and the `callee` uniquely.
*/ */
class IdentifiedRecordedCall extends XMLRecordedCall { class IdentifiedRecordedCall extends XMLRecordedCall {
IdentifiedRecordedCall() { IdentifiedRecordedCall() {

View File

@@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string {
abstract predicate hasActualResult(Location location, string element, string tag, string value); abstract predicate hasActualResult(Location location, string element, string tag, string value);
/** /**
* Holds similarly to `hasActualResult`, but returns results that do not require a matching annotation. * Holds if there is an optional result on the specified location.
*
* This is similar to `hasActualResult`, but returns results that do not require a matching annotation.
* A failure will still arise if there is an annotation that does not match any results, but not vice versa. * A failure will still arise if there is an annotation that does not match any results, but not vice versa.
* Override this predicate to specify optional results. * Override this predicate to specify optional results.
*/ */