forked from python/mypy
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Gobot master #1
Merged
Merged
Gobot master #1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… (and vice versa) (python#12212)
Co-authored-by: hauntsaninja <>
…on#12217) Basically a follow up to python#12203 New errors in typeshed from this: ``` _decimal.__libmpdec_version__ is not present in stub _heapq.__about__ is not present in stub builtins.__build_class__ is not present in stub cgitb.__UNDEF__ is not present in stub decimal.__libmpdec_version__ is not present in stub sys.__unraisablehook__ is not present in stub ``` Some general housekeeping, moving things around, renaming things, adding some comments.
Fixes for python/typeshed#7307 Amusingly, the evil runtime module that is causing havoc is... mypy, which sqlalchemy has some extension for. Co-authored-by: hauntsaninja <>
…hon#12209) The WrapperGenerator is an abstract class for wrapper generation, originally from generate_wrapper_core. The latter one is fully covered by the WrapperGenerator.
Instead of printing `Union[Literal[X], Literal[Y]]`, these are now printed as `Literal[X, Y]`.
Add a link to Python doc about Python C API, which is a friendly tutorial for beginners.
python#9904) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
We used to infer a callable in a protocol against all overload items. This could result in incorrect results, if only one of the overload items would actually match the protocol. Fix the issue by only considering the first matching overload item. This seems to help with protocols involving `__getitem__`. In particular, this fixes regressions related to `SupportsLenAndGetItem`, which is used for `random.choice`.
…hon#7260) (python#12236) This fixes a minor regression.
Closes python#11742 Related python#11743 Related python#11289 Related python#11700
* Adds docs about `Enum` type * Better structure
…ython#7354) (python#12239) Fixes some regressions. Context: python/typeshed#7258
…ython#6935) (python#12240) This fixes some regressions.
This fixes a regression where `iter(x)` could generate a false positive if `x` has a type variable type.
After merging python#11805 I found out that we are missing several new `Enum` features. This PR adds them to the docs. Refs python#12026 Refs python#12035
I'm not adding a test because it's Python 2, but I did test locally. Co-authored-by: hauntsaninja <>
Tests for multi-file and separate compilation modes are a bit special, and it seems useful to have more documentation. Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…1740 (python#11787) Now `__future__` imports do not leak in semanal.py. Closes python#11740 Refs python#11741 Refs python#11276 Refs python#11700
Use renaming to allow two with statements to define the same variable using incompatible types. The implementation is pretty simple-minded and doesn't work in cases where there is even a hint of potential ambiguity about which variant of a variable a reference targets, typically due to functions. This could be generalized to for statements in the future. Fixes python#12246.
Closes python#12258 Closes python#12262
See python/typeshed#5863 Co-authored-by: hauntsaninja <>
This adds a get_class_attribute_hook to plugins to modify attributes on classes (as opposed to the existing get_attribute_hook, which is for attributes on instances). Fixes python#9645
Changes behaviour of PatternChecker so that ValuePattern does not cover the entire (non-literal) type since it can catch only a single value. Fixes: python#12545 Signed-off-by: Štěpán Horáček <xhorace2@fi.muni.cz>
) The dataclass plugin could crash if it encountered a placeholder. Fix the issue by running the plugin after the main semantic analysis pass, when all placeholders have been resolved. Also add a new hook called get_class_decorator_hook_2 that is used by the dataclass plugin. We may want to do a similar change to the attrs plugin, but let's change one thing at a time. Fix python#12685.
…ython#12767) Run the plugin in a later pass to avoid placeholder nodes. Fixes python#11728.
…on#12780) Previously we could export an invalid type for a lambda passed to an overloaded function. We find the matching overload variant by type checking the arguments against all overload items. We exported types for lambdas always from the final potential overload item, even if that wasn't the matching one. This could result in mypyc adding invalid type coercions that could result in bogus TypeErrors. The fix is to store types inferred when looking for matching overload items into temporary type maps, and only the type map from the matching item gets merged into the exported types. This doesn't fully solve the problem -- if there are Any types in the arguments, we can still export invalid types. This should be enough to unblock syncing typeshed (python#12766). Typeshed started triggering the issue in compiled mypy when re.sub was changed to an overloaded function. Work on python#12773.
…on#12772) Move the attrs plugin to a later pass, so that we won't have placeholders. Fix various issues related to forward references and generic inheritance, including some crashes. This is follow-up to python#12762 and related to python#12656 and python#12633.
Source commit: python/typeshed@a27f15e Co-authored-by: hauntsaninja <>
Closes python#8703, which is a crash that was fixed by python#12762
Adds a test case for a crash that was fixed by python#12762. Closes python#12527.
* gettext: Make GNUTranslations.CONTEXT not final (python/typeshed#7841) * sqlite3: Avoid optional type for 'description' (python/typeshed#7842)
This test case cover a recent change in functionality: if an attribute is defined as an InitVar, it can't be assigned to. Previously this was supported (probably by accident).
Make sure the fullname of a named tuple defined within a method matches the nesting of the definition in the symbol table. Otherwise we'll have a crash during deserialization. In particular, a named tuple defined within a method will now be always stored in the symbol table of the surrounding class, instead of the global symbol table. Previously there was an inconsistency between old-style and new-style syntax. Fix python#10913.
Use static analysis to find attributes that are always defined. Always defined attributes don't require checks on each access. This makes them faster and also reduces code size. Attributes defined in the class body and assigned to in all code paths in `__init__` are always defined. We need to know all subclasses statically to determine whether `__init__` always defines an attribute in every case, including in subclasses. The analysis looks at `__init__` methods and supports limited inter-procedural analysis over `super().__init__(...)` calls. Otherwise we rely on intra-procedural analysis to keep the analysis fast. As a side effect, `__init__` will now always be called when constructing an object. This means that `copy.copy` (and others like it) won't be supported for native classes unless `__init__` can be called without arguments. `mypyc/analysis/attrdefined.py` has more details about the algorithm in docstrings. Performance impact to selected benchmarks (with clang): - richards +28% - deltablue +10% - hexiom +1% The richards result is probably an outlier. This will also significantly help with native integers (mypyc/mypyc#837, as tracking undefined values would otherwise require extra memory use. Closes mypyc/mypyc#836.
If we have multiple native attribute access operations in succession, we can borrow the temporaries. This avoids an incref and decref. For example, when evaluating x.y.z, we don't need to incref the result of x.y. We need to make sure that the objects from which we borrow values are not freed too early by adding keep_alive ops. This is part of a wider reference counting optimization workstream. All the improvements together produced around 5% performance improvement in the richards benchmark. In carefully constructed microbenchmarks 50+% improvements are possible.
Borrow an operand such as `x.y` (attribute of a native class) in various contexts when it's safe to do so. This reduces the number of incref/decref operations we need to perform. This continues work started in python#12805. These cases now support borrowing (for some subexpressions, in some contexts): * `x.y is None` * Cast source value * `len(x.y)` (if the operand is a list) * `isinstance(x.y, C)` * `x.y[a.b]` * `x.y.z = 1`
Detect if lxml is importable in the test suite, if it is not, then skip the report tests which depend on it. This is useful for enabling CI on new Python versions that may not have lxml wheels yet. Closes python#11662.
When an invalid python executable is passed to mypy, show an error message instead of crashing.
Diff from mypy_primer, showing the effect of this PR on open source code: discord.py (https://github.com/Rapptz/discord.py)
- version: 0.970+dev.cada36a6bd72fe1b092b7101716257795b527668
+ version: 0.970+dev.8adeedd3ac64bc36659c1462b103dfd12ef1f001
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Have you read the Contributing Guidelines?
(Once you have, delete this section. If you leave it in, your PR may be closed without action.)
Description
(Explain how this PR changes mypy.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)