Consider enum attribute of an unknown type an enum member.
(cherry picked from commit 72c2fd37f18e4dde65d735f1032495df5aeda791)
GitOrigin-RevId: 7e56afe6a2d2efe0ea84ac20672aaf7712d8ed23
Report error for abstract method in non-abstract class.
(cherry picked from commit 824d45a310b95ada628d6e607ae1ced6e351d849)
GitOrigin-RevId: 446cfea2ab76611d13648c17d6f7419fdefa0954
A class containing at least one method declared with `abstractmethod` decorator that hasn’t been overridden yet cannot be instantiated.
Also report instantiation of classes that directly inherit ABC or have metaclass set to ABCMeta.
(cherry picked from commit 55cb4dc90c55ddc63991a4c3f6b50b4e34a3b4bd)
GitOrigin-RevId: b37ea24490dc5ce7dcce87adf21aa6fe31e0e9dc
Convert test files used with the default language level to Python 3 (PyAbstractInspectionTest)
(cherry picked from commit debae3365955d6237c423197ec25a638dbd95dfb)
GitOrigin-RevId: 66f17df6866682c5e18a6f43a861e628ddb0ba30
It can be null if, for example, a Python interpreter is not configured and a tuple of strings is used as a rightExpression
(cherry picked from commit 23564503422a75de7b538dec3400fb8dd284cd73)
IJ-MR-159172
GitOrigin-RevId: 0bb36753d66f81afc784e88d8d7cd84b5795997c
Added PyWithContextExitInstruction that works as 'except' node in try-except statements, but for 'with context-manager' statements. This allows to see when it can recover from exception by checking the type of `contextlib.AbstractContextManager`
Merge-request: IJ-MR-152213
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>
GitOrigin-RevId: fd5a139de31d47136cc86b4a7e090a20b73b8744
Subtypes of types constrained by a type variable should be treated as their respective explicitly listed base types in the context of the type variable.
GitOrigin-RevId: ecaac1614f66974b6e6c2217ac0a90321d049f76
Update test data.
1. Unresolved imports are not removed with optimize imports
2. Unresolved imports are not marked as unused
GitOrigin-RevId: 2c32c368ae0907fb75ea76fc9749e903c160667c
The logic for disabling the unused warning on unresolved imports was dependent on the visit order. Moving sustracting unresolved imports to the end of computation fixes the problem.
GitOrigin-RevId: adeb85e59c17261a5bf9f64dfb4a7836a2403f43
These were added even before .pyi stubs for `mock` and `unittest.mock`
were enabled, so they have been unnecessary for a long while.
GitOrigin-RevId: 844667e63263fcc88cdda58e5140c6b59a6825af
Infer typed dict type from TypedDict() call even in case of an unexpected arguments list.
Also changed incorrect TypedDict() signature:
from (name: str, fields: dict[str, Any], total: bool = True) -> Any
to (typename: str, fields: dict[str, type], *, /, total: bool = True) -> Any
GitOrigin-RevId: 94c1ebb4fe3026744cb9771eab9e5ba507d049fa
Now that we have proper support for Literal types and overloads,
we can infer the right return type automatically.
It breaks custom type inference for the "open" function in Python 2
because of their outdated stubs not using Literal type for the "mode"
argument. The stubs for Python 2 are no longer included in Typeshed,
so we keep an old snapshot of them. However, breaking it seems
acceptable nowadays, and if the need ever arises, we should better
customize our copy of .pyi stubs for Python 2.
GitOrigin-RevId: cd18252976959e81e2412f0433edc66e8e9ccfc5
Previously, we mistakenly tried to resolve qualified names listed in the
`field_specifiers` argument of @dataclass_transform in the same scope
where the dataclass itself is defined, not where the actual decorator
application is located.
Thus, if in the file where the dataclass is defined, a field specifier
was imported differently than where @dataclass_transform was applied, we
couldn't recognize a field specifier call in the RHS of an assignment as such
and took it for an ordinary field default value.
In particular, this is what happened with pydantic dataclasses.
`pydantic.fields.Field` is usually imported as just `pydantic.Field` where
user dataclasses are defined, but imported with an alias and set in the
`field_specifiers` argument as `PydanticModelField` in
`pydantic._internal._model_construction` where `ModelMetaclass` is defined.
It was accidentally broken in f15a07836e7aeac7c46b489b4742e8248a0e6ef4 to
support decorating class methods with dataclass_transform
(see testData/inspections/PyDataclassInspection/DataclassTransformFieldsOrder/decorator.py).
Until PyResolveUtil.resolveQualifiedNameInScope automatically traverses through
containing scopes looking for a name, the file containing decorator application
seems like a safe trade-off for the scope, because field specifiers are normally
defined or imported somewhere at the top level.
GitOrigin-RevId: de9afeb0831a52f058453fe678de229d41c26a4d
Check YieldType of yield expressions in PyTypeCheckerInspection
Check that (Async)Generator is used in (async) function
Check that in 'yield from' sync Generator is used
Convert PyMakeFunctionReturnTypeQuickFix into PsiUpdateModCommandAction
Infer Generator type for lambdas
When getting function type from annotation, do not convert Generator to AsyncGenerator
Introduce GeneratorTypeDescriptor to simplify working with generator annotations
Merge-request: IJ-MR-146521
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>
GitOrigin-RevId: b3b8182168c5224f0e03f54d443171ccf6ca7b89
Updated PyFunction to account for implicit 'return None' statements when inferring return statement types.
It affected return type inference of PyFunction.
Fixed a failing test related to formatted strings.
Added a quick fix to make all return statements explicit.
Updated the CFG to include PyPassStatements, enabling detection of exit points in empty functions.
Simplified PyMakeFunctionReturnTypeQuickFix to independently infer function types and handle required imports. Currently, it does not support specifying custom suggested types.
Merge-request: IJ-MR-148719
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>
GitOrigin-RevId: 9f58961f9eb70e4f9dbba7359f5aafdfd392b7e2
Previously, PyTypingTypeProvider.getReferenceType returned a type from a class attribute
type hint only for assignment to instance attribute located inside a class definition.
In other words, here we inferred the expected type from the annotation
and reported incompatible types in assignment:
```python
class C:
attr: int
def m(self):
self.attr = "foo"
```
but in the following we didn't:
```python
class C:
attr: int
inst = C()
inst.attr = "foo"
```
Now we try to resolve any qualified target expression to a class
or instance attribute and then infer the type from the corresponding
annotation.
GitOrigin-RevId: 086dbb678a8cd89cfe332bf801631568fb6c3a4d
Previously, we reported call arguments only if either all callee
candidates have unmatched arguments or all call candidates have
unmatched parameters. When there was a mix of the two, we reported
nothing.
GitOrigin-RevId: 97b42faf10de74ee7cd10f934d9eb94e1c8bbb34