Skip to content

Commit

Permalink
Merge pull request #541 from lsst/tickets/DM-30855
Browse files Browse the repository at this point in the history
DM-30855: Fix support for click 8.x
  • Loading branch information
timj committed Jun 23, 2021
2 parents fd66196 + a233321 commit 5a94d85
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions doc/changes/DM-30855.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for click 8.0.
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def convert(self, value, param, ctx):
"""Called by click.ParamType to "convert values through types".
`click.Path` uses this step to verify Path conditions."""
if self.mustNotExist and os.path.exists(value):
self.fail(f'{self.path_type} "{value}" should not exist.')
self.fail(f'Path "{value}" should not exist.')
return super().convert(value, param, ctx)


Expand Down
10 changes: 5 additions & 5 deletions python/lsst/daf/butler/tests/cliLogTestBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def hasLsstLogHandler(logger):


@click.command()
@click.option("--expected-pyroot-level")
@click.option("--expected-pybutler-level")
@click.option("--expected-lsstroot-level")
@click.option("--expected-lsstbutler-level")
@click.option("--expected-pyroot-level", type=int)
@click.option("--expected-pybutler-level", type=int)
@click.option("--expected-lsstroot-level", type=int)
@click.option("--expected-lsstbutler-level", type=int)
def command_log_settings_test(expected_pyroot_level,
expected_pybutler_level,
expected_lsstroot_level,
Expand All @@ -92,7 +92,7 @@ def command_log_settings_test(expected_pyroot_level,
"lsstButler")])
for expected, actual, name in logLevels:
if expected != actual:
raise(click.ClickException(f"expected {name} level to be {expected}, actual:{actual}"))
raise(click.ClickException(f"expected {name} level to be {expected!r}, actual:{actual!r}"))


class CliLogTestBase():
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pyyaml >= 5.1
astropy >= 4.0
click >7.0,<8.0
click >7.0
sqlalchemy >= 1.3
git+git://github.com/lsst/sphgeom@master#egg=lsst_sphgeom
pydantic
Expand Down
7 changes: 2 additions & 5 deletions tests/test_cliUtilSplitKv.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,11 @@ def cli(metasyntactic_var):
self.assertEqual(result.exit_code, 0, msg=clickResultMsg(result))
mock.assert_called_with({"lsst.daf.butler": "BAR"})

# check invalid choices with and wihtout kv separators
# check that invalid choices with and wihtout kv separators fail &
# return a non-zero exit code.
for val in ("BOZ", "lsst.daf.butler=BOZ"):
result = self.runner.invoke(cli, ["--metasyntactic-var", val])
self.assertNotEqual(result.exit_code, 0, msg=clickResultMsg(result))
self.assertRegex(result.output,
r"Error: Invalid value for ['\"]\-\-metasyntactic-var['\"]:")
self.assertIn(f" invalid choice: BOZ. (choose from {', '.join(choices)})",
result.output)

# check value normalization (lower case "foo" should become "FOO")
result = self.runner.invoke(cli, ["--metasyntactic-var", "lsst.daf.butler=foo"])
Expand Down

0 comments on commit 5a94d85

Please sign in to comment.