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

Improve types for REPL #2007

Merged
merged 7 commits into from
Feb 12, 2024
Merged

Improve types for REPL #2007

merged 7 commits into from
Feb 12, 2024

Conversation

alexrudd2
Copy link
Collaborator

Closes #2006

Also reduces a further 15 mypy errors and deletes some junk.

@@ -88,12 +88,6 @@ def convert(self, value, param, ctx):
if value in self.choices:
return self.typ(value)

if ctx is not None and ctx.token_normalize_func is not None:
value = ctx.token_normalize_func(value)
for choice in self.casted_choices: # pylint: disable=no-member
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I searched for casted_choices in git history as well as Click project, and could not find it anywhere.

@@ -342,7 +332,7 @@ def tcp(ctx, host, port, framer):
"PARITY_NONE, PARITY_EVEN, PARITY_ODD PARITY_MARK, "
'PARITY_SPACE. Default to "N"',
default="N",
type=CaseInsenstiveChoice(["N", "E", "O", "M", "S"]),
type=click.Choice(["N", "E", "O", "M", "S"], case_sensitive=False),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this will automatically normalize to the values in the list (upper case) so we can kill CaseInsensitiveChoice class entirely

alex@antorak:~/git/pymodbus$ pymodbus.console serial --port /dev/blah --parity e
> client.get_parity
"E"

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

Is your problem solved ?

@@ -38,7 +38,7 @@
| | \___ / Y ( <_> ) /_/ | | | \ ___/| |_> > |__
|____| / ____\____|__ /\____/\____ | /\ |____|_ /\___ > __/|____/
\/ \/ \/ \/ \/ \/|__|
v1.3.0 - {pymodbus_version}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should really change this to refer to the version in pymodbus/init

@janiversen janiversen merged commit b34eb46 into dev Feb 12, 2024
1 check passed
@janiversen janiversen deleted the repl-types branch February 12, 2024 07:03
@alexrudd2
Copy link
Collaborator Author

alexrudd2 commented Feb 12, 2024

Is your problem solved ?

Not sure. I submitted this PR from my home machine (not at work), and was only looking at pyright output. I created the issue for the benefit of anyone else who may be searching the issue tracker. (They might run into it on a released version even if we have fixed in dev)

Today I have installed pymodbus (from pip not git) on a work machine, which led to #2008

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REPL client params are broken
2 participants