FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Drop deprecated, type-specific options in favor of --type (#336) · pillarsdotnet/python-kasa@4dbdb5a · GitHub

Repository navigation

Commit 4dbdb5a

Browse files
authored
Drop deprecated, type-specific options in favor of --type (python-kasa#336)
* Drop deprecated, type-specific options in favor of --type * Fix tests
1 parent 6af8086 commit 4dbdb5a

2 files changed

Lines changed: 3 additions & 38 deletions

File tree

‎kasa/cli.py‎

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353
help="The broadcast address to be used for discovery.",
5454
)
5555
@click.option("-d", "--debug", envvar="KASA_DEBUG", default=False, is_flag=True)
56-
@click.option("--bulb", default=False, is_flag=True)
57-
@click.option("--plug", default=False, is_flag=True)
58-
@click.option("--lightstrip", default=False, is_flag=True)
59-
@click.option("--strip", default=False, is_flag=True)
6056
@click.option(
6157
"--type",
6258
envvar="KASA_TYPE",
@@ -65,7 +61,7 @@
6561
)
6662
@click.version_option(package_name="python-kasa")
6763
@click.pass_context
68-
async def cli(ctx, host, alias, target, debug, bulb, plug, lightstrip, strip, type):
64+
async def cli(ctx, host, alias, target, debug, type):
6965
"""A tool for controlling TP-Link smart home devices.""" # noqa
7066
# no need to perform any checks if we are just displaying the help
7167
if sys.argv[-1] == "--help":
@@ -95,19 +91,6 @@ async def cli(ctx, host, alias, target, debug, bulb, plug, lightstrip, strip, ty
9591
await ctx.invoke(discover)
9692
return
9793

98-
if bulb or plug or strip or lightstrip:
99-
click.echo(
100-
"Using --bulb, --plug, --strip, and --lightstrip is deprecated. Use --type instead to define the type"
101-
)
102-
if bulb:
103-
type = "bulb"
104-
elif plug:
105-
type = "plug"
106-
elif strip:
107-
type = "strip"
108-
elif lightstrip:
109-
type = "lightstrip"
110-
11194
if type is not None:
11295
dev = TYPE_TO_CLASS[type](host)
11396
else:
@@ -158,9 +141,8 @@ async def join(dev: SmartDevice, ssid, password, keytype):
158141

159142
@cli.command()
160143
@click.option("--timeout", default=3, required=False)
161-
@click.option("--dump-raw", is_flag=True)
162144
@click.pass_context
163-
async def discover(ctx, timeout, dump_raw):
145+
async def discover(ctx, timeout):
164146
"""Discover devices in the network."""
165147
target = ctx.parent.params["target"]
166148
click.echo(f"Discovering devices on {target} for {timeout} seconds")
@@ -201,8 +183,7 @@ async def sysinfo(dev):
201183

202184
@cli.command()
203185
@pass_dev
204-
@click.pass_context
205-
async def state(ctx, dev: SmartDevice):
186+
async def state(dev: SmartDevice):
206187
"""Print out device state and versions."""
207188
click.echo(click.style(f"== {dev.alias} - {dev.model} ==", bold=True))
208189
click.echo(f"\tHost: {dev.host}")

‎kasa/tests/test_cli.py‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,6 @@ async def test_brightness(dev):
106106
assert "Brightness: 12" in res.output
107107

108108

109-
def _generate_type_class_pairs():
110-
yield from TYPE_TO_CLASS.items()
111-
112-
113-
@pytest.mark.parametrize("type_class", _generate_type_class_pairs())
114-
async def test_deprecated_type(dev, type_class, mocker):
115-
"""Make sure that using deprecated types yields a warning."""
116-
type, cls = type_class
117-
if type == "dimmer":
118-
return
119-
runner = CliRunner()
120-
with mocker.patch("kasa.SmartDevice.update"):
121-
res = await runner.invoke(cli, ["--host", "127.0.0.2", f"--{type}"])
122-
assert "Using --bulb, --plug, --strip, and --lightstrip is deprecated" in res.output
123-
124-
125109
async def test_temperature(dev):
126110
pass
127111

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL