Skip to content

Commit

Permalink
Replaced YAPF comments with black comments
Browse files Browse the repository at this point in the history
We replaced YAPF with black in #265, but forgot to update the comments
to turn formatting off on a small number of snippets where the default
formatting was unreadable.

In this patch, we replaced the comments to instruct black to skip these
snippets.
  • Loading branch information
mristin committed Oct 4, 2023
1 parent 729d17b commit e1336ec
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 54 deletions.
16 changes: 8 additions & 8 deletions benchmarks/against_others/compare_invariant.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,22 @@ def measure_invariant_at_init() -> None:
table = [] # type: List[List[str]]

for cls, duration in zip(clses, durations):
# yapf: disable
# fmt: off
table.append([
'`{}`'.format(cls),
'{:.2f} s'.format(duration),
'{:.2f} μs'.format(duration * 1000 * 1000 / number),
'{:.0f}%'.format(duration * 100 / durations[0])
])
# yapf: enable
# fmt: on

# yapf: disable
# fmt: off
table_str = tabulate.tabulate(
table,
headers=['Case', 'Total time', 'Time per run', 'Relative time per run'],
colalign=('left', 'right', 'right', 'right'),
tablefmt='rst')
# yapf: enable
# fmt: on

writeln_utf8(table_str)

Expand All @@ -130,22 +130,22 @@ def measure_invariant_at_function() -> None:
table = [] # type: List[List[str]]

for cls, duration in zip(clses, durations):
# yapf: disable
# fmt: off
table.append([
'`{}`'.format(cls),
'{:.2f} s'.format(duration),
'{:.2f} μs'.format(duration * 1000 * 1000 / number),
'{:.0f}%'.format(duration * 100 / durations[0])
])
# yapf: enable
# fmt: on

# yapf: disable
# fmt: off
table_str = tabulate.tabulate(
table,
headers=['Case', 'Total time', 'Time per run', 'Relative time per run'],
colalign=('left', 'right', 'right', 'right'),
tablefmt='rst')
# yapf: enable
# fmt: on

writeln_utf8(table_str)

Expand Down
8 changes: 4 additions & 4 deletions benchmarks/against_others/compare_postcondition.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ def measure_functions() -> None:
table = [] # type: List[List[str]]

for func, duration in zip(funcs, durations):
# yapf: disable
# fmt: off
table.append([
'`{}`'.format(func),
'{:.2f} s'.format(duration),
'{:.2f} μs'.format(duration * 1000 * 1000 / number),
'{:.0f}%'.format(duration * 100 / durations[0])
])
# yapf: enable
# fmt: on

# yapf: disable
# fmt: off
table_str = tabulate.tabulate(
table,
headers=['Case', 'Total time', 'Time per run', 'Relative time per run'],
colalign=('left', 'right', 'right', 'right'),
tablefmt='rst')
# yapf: enable
# fmt: on

writeln_utf8(table_str)

Expand Down
8 changes: 4 additions & 4 deletions benchmarks/against_others/compare_precondition.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ def measure_functions() -> None:
table = [] # type: List[List[str]]

for func, duration in zip(funcs, durations):
# yapf: disable
# fmt: off
table.append([
'`{}`'.format(func),
'{:.2f} s'.format(duration),
'{:.2f} μs'.format(duration * 1000 * 1000 / number),
'{:.0f}%'.format(duration * 100 / durations[0])
])
# yapf: enable
# fmt: on

# yapf: disable
# fmt: off
table_str = tabulate.tabulate(
table,
headers=['Case', 'Total time', 'Time per run', 'Relative time per run'],
colalign=('left', 'right', 'right', 'right'),
tablefmt='rst')
# yapf: enable
# fmt: on

writeln_utf8(table_str)

Expand Down
4 changes: 2 additions & 2 deletions icontract/_recompute.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,13 +658,13 @@ def visit_Call(self, node: ast.Call) -> Any:
)

# Short-circuit tracing the all quantifier over a generator expression
# yapf: disable
# fmt: off
if (
func == builtins.all # pylint: disable=comparison-with-callable
and len(node.args) == 1
and isinstance(node.args[0], ast.GeneratorExp)
):
# yapf: enable
# fmt: on
result = self._trace_all_with_generator(func=func, node=node)

if result is PLACEHOLDER:
Expand Down
4 changes: 2 additions & 2 deletions icontract/_represent.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def inspect_lambda_condition(
return lambda_inspection


# yapf: disable
# fmt: off
def collect_variable_lookup(
condition: Callable[..., Any],
resolved_kwargs: Optional[Mapping[str, Any]] = None
Expand All @@ -443,7 +443,7 @@ def collect_variable_lookup(
The keyword arguments are added to the variable look-up tables accordingly.
If ``resolved_kwargs`` is None, no keyword arguments will be added to the variable look-up table.
"""
# yapf: enable
# fmt: on
variable_lookup = [] # type: List[Mapping[str, Any]]

##
Expand Down
8 changes: 4 additions & 4 deletions precommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,24 @@ def main() -> int:
env = os.environ.copy()
env["ICONTRACT_SLOW"] = "true"

# yapf: disable
# fmt: off
subprocess.check_call(
["coverage", "run",
"--source", "icontract",
"-m", "unittest", "discover"],
cwd=str(repo_root),
env=env)
# yapf: enable
# fmt: on

if sys.version_info >= (3, 8):
# yapf: disable
# fmt: off
subprocess.check_call(
["coverage", "run",
"--source", "icontract",
"-a", "-m", "tests_3_8.async.separately_test_concurrent"],
cwd=str(repo_root),
env=env)
# yapf: enable
# fmt: on

subprocess.check_call(["coverage", "report"])

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
author="Marko Ristin",
author_email="marko@ristin.ch",
classifiers=[
# yapf: disable
# fmt: off
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
Expand All @@ -41,7 +41,7 @@
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10'
# yapf: enable
# fmt: on
],
license="License :: OSI Approved :: MIT License",
keywords="design-by-contract precondition postcondition validation",
Expand Down

0 comments on commit e1336ec

Please sign in to comment.