-
Notifications
You must be signed in to change notification settings - Fork 109
Strict detection of tmux version via regex #397
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far. Good catch and nice job.
- We may want to test for
get_version()
test 3.2a and 3.2 - I have a regex here: https://github.com/tmux-python/libtmux/blob/d4c9af5/tests/test_common.py#L32, interestingly I don't fetch the letter either
@@ -552,7 +552,7 @@ def get_version() -> LooseVersion: | |||
) | |||
raise exc.VersionTooLow(proc.stderr) | |||
|
|||
version = proc.stdout[0].split("tmux ")[1] | |||
version = re.search('[0-9]{1}.[0-9]', proc.stdout[0]).group(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about line 561, wouldn't this lose access to the a in 3.2a?
@@ -552,7 +552,7 @@ def get_version() -> LooseVersion: | |||
) | |||
raise exc.VersionTooLow(proc.stderr) | |||
|
|||
version = proc.stdout[0].split("tmux ")[1] | |||
version = re.search('[0-9]{1}.[0-9]', proc.stdout[0]).group(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
poetry run mypy .
libtmux/common.py:555: error: Item "None" of "Optional[Match[str]]" has no attribute "group"
This will need null-checks to handle empty matches. I haven't tested, but it'd be something like
version = re.search('[0-9]{1}.[0-9]', proc.stdout[0]).group(0) | |
match = re.search('[0-9]{1}.[0-9]', proc.stdout[0]) | |
assert match is not None | |
version = match.group(0) |
@mdeguzis I will give your PR priority review if you have more commits I can also take a stab at it (but would be happy if yours got in so you get credit!) |
I should be able to look at the comments this week and see what I can do. |
@mdeguzis That sounds fine! |
@mdeguzis Is this a PR you're still interested in? |
d3613a0
to
0c76816
Compare
f15027f
to
8baa764
Compare
See: #396
This change uses a more precise regex method to grab the tmux version string, taking into account the many variations of tmux versions:
I tested my change locally with tmuxp as well:
Testing with python3:
Regex 101 test: https://regex101.com/r/y7jsSJ/1