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

fix locale parsing on Linux #834

Merged
merged 2 commits into from
Oct 31, 2024
Merged

Conversation

arenekosreal
Copy link
Contributor

Linux uses locale string en_US.utf-8 instead en-us.utf-8. So I added a statement to convert between them correctly.

Linux uses locale string `en_US.utf-8` instead `en-us.utf-8`.
So I added a statement to convert between them correctly.
Copy link
Owner

@DetachHead DetachHead left a comment

Choose a reason for hiding this comment

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

hmm i guess that VSCODE_NLS_CONFIG variable uses a different format to everything else. thanks!

This comment has been minimized.

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

sympy (https://github.com/sympy/sympy)
-     Type of "eq" is "_NotImplementedType | Unknown" (reportUnknownVariableType)
+     Type of "eq" is "_NotImplementedType | GreaterThan | Unknown | Equality | Relational | Unequality" (reportUnknownVariableType)
-     Type of "default_sort_key" is "(item: Unknown, order: Unknown | None = None) -> (tuple[tuple[Literal[5], Literal[0], str], tuple[int, tuple[Unknown, ...]], Unknown, Unknown] | Unknown | tuple[tuple[int, int, str | Unknown], tuple[int, tuple[Unknown, ...]] | tuple[int, tuple[str]], Unknown, Unknown])" (reportUnknownVariableType)
+     Type of "default_sort_key" is "(item: Unknown, order: Unknown | None = None) -> (tuple[Unknown, tuple[int, tuple[Unknown, ...]], Unknown, Unknown] | Unknown | tuple[tuple[int, int, str | Unknown], tuple[int, tuple[Unknown, ...]] | tuple[int, tuple[str]], Unknown, Unknown])" (reportUnknownVariableType)
-     Argument type is "(item: Unknown, order: Unknown | None = None) -> (tuple[tuple[Literal[5], Literal[0], str], tuple[int, tuple[Unknown, ...]], Unknown, Unknown] | Unknown | tuple[tuple[int, int, str | Unknown], tuple[int, tuple[Unknown, ...]] | tuple[int, tuple[str]], Unknown, Unknown])" (reportUnknownArgumentType)
+     Argument type is "(item: Unknown, order: Unknown | None = None) -> (tuple[Unknown, tuple[int, tuple[Unknown, ...]], Unknown, Unknown] | Unknown | tuple[tuple[int, int, str | Unknown], tuple[int, tuple[Unknown, ...]] | tuple[int, tuple[str]], Unknown, Unknown])" (reportUnknownArgumentType)
-     Argument type is "(item: Unknown, order: Unknown | None = None) -> (tuple[tuple[Literal[5], Literal[0], str], tuple[int, tuple[Unknown, ...]], Unknown, Unknown] | Unknown | tuple[tuple[int, int, str | Unknown], tuple[int, tuple[Unknown, ...]] | tuple[int, tuple[str]], Unknown, Unknown])" (reportUnknownArgumentType)
+     Argument type is "(item: Unknown, order: Unknown | None = None) -> (tuple[Unknown, tuple[int, tuple[Unknown, ...]], Unknown, Unknown] | Unknown | tuple[tuple[int, int, str | Unknown], tuple[int, tuple[Unknown, ...]] | tuple[int, tuple[str]], Unknown, Unknown])" (reportUnknownArgumentType)
-     Argument type is "(item: Unknown, order: Unknown | None = None) -> (tuple[tuple[Literal[5], Literal[0], str], tuple[int, tuple[Unknown, ...]], Unknown, Unknown] | Unknown | tuple[tuple[int, int, str | Unknown], tuple[int, tuple[Unknown, ...]] | tuple[int, tuple[str]], Unknown, Unknown])" (reportUnknownArgumentType)
+     Argument type is "(item: Unknown, order: Unknown | None = None) -> (tuple[Unknown, tuple[int, tuple[Unknown, ...]], Unknown, Unknown] | Unknown | tuple[tuple[int, int, str | Unknown], tuple[int, tuple[Unknown, ...]] | tuple[int, tuple[str]], Unknown, Unknown])" (reportUnknownArgumentType)
-     Type of "evalf" is "Unknown | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Equality | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Relational | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Unequality | EvalfMixin* | Any))" (reportUnknownMemberType)
+     Type of "evalf" is "Unknown | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Equality | EvalfMixin* | Any | Float)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Relational | EvalfMixin* | Any | Float)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Unequality | EvalfMixin* | Any | Float))" (reportUnknownMemberType)
-     Type of "evalf" is "Unknown | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Equality | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Relational | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Unequality | EvalfMixin* | Any))" (reportUnknownMemberType)
+     Type of "evalf" is "Unknown | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Equality | EvalfMixin* | Any | Float)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Relational | EvalfMixin* | Any | Float)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Unequality | EvalfMixin* | Any | Float))" (reportUnknownMemberType)
-     Type of "evalf" is "Unknown | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Mul | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Expectation | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Sum | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Self@Expr | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Order | EvalfMixin* | Any)) | Any | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Piecewise | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Equality | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Relational | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Unequality | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | Integral | EvalfMixin* | Any)) | ((n: int = 15, subs: Unknown | None = None, maxn: int = 100, chop: bool = False, strict: bool = False, quad: Unknown | None = None, verbose: bool = False) -> (Unknown | ExpectationMatrix | EvalfMixin* | Any))" (reportUnknownMemberType)

... (truncated 85 lines) ...

comtypes (https://github.com/enthought/comtypes): 277.37x slower (0.1s -> 24.8s in a single noisy sample)

@DetachHead DetachHead merged commit 35d03dc into DetachHead:main Oct 31, 2024
16 checks passed
@NCBM
Copy link
Contributor

NCBM commented Nov 19, 2024

Although this fix is already accepted here a few weeks ago, I'm very glad to see it.

hmm i guess that VSCODE_NLS_CONFIG variable uses a different format to everything else. thanks!

Yes, and exactly locale names are slightly different generally in the whole Windows. From Locale names in Windows CRT Documentation we can know that the en-us-style names comes from IETF BCP47 and are different from names on linux.

About a few days before this PR, I created an issue microsoft/pyright#9269 about this and I've been told it is as designed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants