Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-30855: Fix support for click 8.x #541

Merged
merged 5 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that in click 8 they changed .path_type to .type (presumably for consistency).

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