提交 5e8398b5 authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Update OptimizationQuery's docstrings

上级 4e0fcb7d
...@@ -194,19 +194,19 @@ class OptimizationQuery: ...@@ -194,19 +194,19 @@ class OptimizationQuery:
========== ==========
include: include:
A set of tags such that every optimization obtained through this A set of tags such that every optimization obtained through this
``OptimizationQuery`` must have **one** of the tags listed. This `OptimizationQuery` must have **one** of the tags listed. This
field is required and basically acts as a starting point for the field is required and basically acts as a starting point for the
search. search.
require: require:
A set of tags such that every optimization obtained through this A set of tags such that every optimization obtained through this
``OptimizationQuery`` must have **all** of these tags. `OptimizationQuery` must have **all** of these tags.
exclude: exclude:
A set of tags such that every optimization obtained through this A set of tags such that every optimization obtained through this
``OptimizationQuery`` must have **none** of these tags. ``OptimizationQuery` must have **none** of these tags.
subquery: subquery:
A dictionary mapping the name of a sub-database to a special A dictionary mapping the name of a sub-database to a special
``OptimizationQuery``. If no subquery is given for a sub-database, `OptimizationQuery`. If no subquery is given for a sub-database,
the original ``OptimizationQuery`` will be used again. the original `OptimizationQuery` will be used again.
position_cutoff: position_cutoff:
Only optimizations with position less than the cutoff are returned. Only optimizations with position less than the cutoff are returned.
extra_optimizations: extra_optimizations:
...@@ -241,8 +241,8 @@ class OptimizationQuery: ...@@ -241,8 +241,8 @@ class OptimizationQuery:
if not hasattr(self, "extra_optimizations"): if not hasattr(self, "extra_optimizations"):
self.extra_optimizations = [] self.extra_optimizations = []
# add all opt with this tag def including(self, *tags: str) -> "OptimizationQuery":
def including(self, *tags): """Add rewrites with the given tags."""
return OptimizationQuery( return OptimizationQuery(
self.include.union(tags), self.include.union(tags),
self.require, self.require,
...@@ -252,8 +252,8 @@ class OptimizationQuery: ...@@ -252,8 +252,8 @@ class OptimizationQuery:
self.extra_optimizations, self.extra_optimizations,
) )
# remove all opt with this tag def excluding(self, *tags: str) -> "OptimizationQuery":
def excluding(self, *tags): """Remove rewrites with the given tags."""
return OptimizationQuery( return OptimizationQuery(
self.include, self.include,
self.require, self.require,
...@@ -263,8 +263,8 @@ class OptimizationQuery: ...@@ -263,8 +263,8 @@ class OptimizationQuery:
self.extra_optimizations, self.extra_optimizations,
) )
# keep only opt with this tag. def requiring(self, *tags: str) -> "OptimizationQuery":
def requiring(self, *tags): """Filter for rewrites with the given tags."""
return OptimizationQuery( return OptimizationQuery(
self.include, self.include,
self.require.union(tags), self.require.union(tags),
...@@ -274,7 +274,8 @@ class OptimizationQuery: ...@@ -274,7 +274,8 @@ class OptimizationQuery:
self.extra_optimizations, self.extra_optimizations,
) )
def register(self, *optimizations): def register(self, *optimizations: Sequence[OptimizersType]) -> "OptimizationQuery":
"""Include the given optimizations."""
return OptimizationQuery( return OptimizationQuery(
self.include, self.include,
self.require, self.require,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论