Skip to content

Commit

Permalink
Add asv version as cmdline argument
Browse files Browse the repository at this point in the history
  • Loading branch information
camposandro committed Oct 30, 2023
1 parent 088e037 commit dda46e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/lf_asv_formatter/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
"""Main file to call from command line and GitHub workflows."""
import asv
import argparse

Check warning on line 2 in src/lf_asv_formatter/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/lf_asv_formatter/__main__.py#L2

Added line #L2 was not covered by tests

from .simple_formatter import SimpleFormatter
from .tabulate_formatter import TabulateFormatter

Check warning on line 5 in src/lf_asv_formatter/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/lf_asv_formatter/__main__.py#L4-L5

Added lines #L4 - L5 were not covered by tests


def parse_asv_version():
parser = argparse.ArgumentParser("lf_asv_formatter")
parser.add_argument("--asv_version", help="Version of asv", type=str, required=True)
return parser.parse_args().asv_version

Check warning on line 11 in src/lf_asv_formatter/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/lf_asv_formatter/__main__.py#L8-L11

Added lines #L8 - L11 were not covered by tests


if __name__ == "__main__":
if asv.__version__ >= "0.6.0":
SimpleFormatter().rewrite_file()
else:
TabulateFormatter().rewrite_file()
asv_version = parse_asv_version()
formatter = SimpleFormatter() if asv_version >= "0.6.0" else TabulateFormatter()
formatter.rewrite_file()

Check warning on line 17 in src/lf_asv_formatter/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/lf_asv_formatter/__main__.py#L14-L17

Added lines #L14 - L17 were not covered by tests
2 changes: 1 addition & 1 deletion src/lf_asv_formatter/simple_formatter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .asv_formatter import AsvFormatter


# pylint: disable=line-too-long


class SimpleFormatter(AsvFormatter):
"""The SimpleFormatter is used for asv >= 0.6.0.
Expand Down

0 comments on commit dda46e4

Please sign in to comment.