-
Notifications
You must be signed in to change notification settings - Fork 83
mypy: Fix all union-attr #366
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -232,14 +232,9 @@ def grok_environment_error(exc: object, prefix: str = "error: ") -> str: | |
|
|
||
|
|
||
| # Needed by 'split_quoted()' | ||
| _wordchars_re = _squote_re = _dquote_re = None | ||
|
|
||
|
|
||
| def _init_regex(): | ||
| global _wordchars_re, _squote_re, _dquote_re | ||
| _wordchars_re = re.compile(rf'[^\\\'\"{string.whitespace} ]*') | ||
| _squote_re = re.compile(r"'(?:[^'\\]|\\.)*'") | ||
| _dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"') | ||
| _wordchars_re = re.compile(rf'[^\\\'\"{string.whitespace} ]*') | ||
| _squote_re = re.compile(r"'(?:[^'\\]|\\.)*'") | ||
| _dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"') | ||
|
Comment on lines
+235
to
+237
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't exactly "heavy computing" is it? Did it need to be done lazily ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Looks like premature optimization. Even the |
||
|
|
||
|
|
||
| def split_quoted(s: str) -> list[str]: | ||
|
|
@@ -256,15 +251,14 @@ def split_quoted(s: str) -> list[str]: | |
| # This is a nice algorithm for splitting up a single string, since it | ||
| # doesn't require character-by-character examination. It was a little | ||
| # bit of a brain-bender to get it working right, though... | ||
| if _wordchars_re is None: | ||
| _init_regex() | ||
|
|
||
| s = s.strip() | ||
| words = [] | ||
| pos = 0 | ||
|
|
||
| while s: | ||
| m = _wordchars_re.match(s, pos) | ||
| assert m is not None | ||
| end = m.end() | ||
| if end == len(s): | ||
| words.append(s[:end]) | ||
|
|
@@ -305,9 +299,6 @@ def split_quoted(s: str) -> list[str]: | |
| return words | ||
|
|
||
|
|
||
| # split_quoted () | ||
|
|
||
|
|
||
| def execute( | ||
| func: Callable[[Unpack[_Ts]], object], | ||
| args: tuple[Unpack[_Ts]], | ||
|
|
||
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.
I mentioned in another PR - I'm not sure these changes are stable. I'm worried there are edge cases that would begin to fail with this change. Let's be confident that this change doesn't break anything (and consider using casts to retain the current behavior if appropriate).