Modernize code to Python 3.6+ (#1158)

* Compact dict and set building
* Remove redundant parentheses
* Simplify chained conditions
* Change method name to lowercase
* Use triple double quotes for docstrings

Thanks, @eumiro!
This commit is contained in:
Miroslav Šedivý 2020-12-23 18:04:32 +01:00 committed by GitHub
commit a882d67962
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 76 additions and 82 deletions

View file

@ -15,7 +15,7 @@ label_re = re.compile(r"\.\. _([^\s:]+):")
def get_headings(content, underline="-"):
heading_re = re.compile(r"(\w+)(\([^)]*\))?\n\{}+\n".format(underline))
return set(h[0] for h in heading_re.findall(content))
return {h[0] for h in heading_re.findall(content)}
def get_labels(filename):
@ -96,11 +96,11 @@ def documented_table_filters():
json_api_rst = (docs_path / "json_api.rst").read_text()
section = json_api_rst.split(".. _table_arguments:")[-1]
# Lines starting with ``?column__exact= are docs for filters
return set(
return {
line.split("__")[1].split("=")[0]
for line in section.split("\n")
if line.startswith("``?column__")
)
}
@pytest.mark.parametrize("filter", [f.key for f in Filters._filters])