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

Exception in PyCharm plugin Pydantic (0.3.4) #353

Closed
mahenzon opened this issue Aug 25, 2021 · 3 comments
Closed

Exception in PyCharm plugin Pydantic (0.3.4) #353

mahenzon opened this issue Aug 25, 2021 · 3 comments

Comments

@mahenzon
Copy link

Describe the bug
Fatal Error appeared while editing code (not envolving pydantic models, but they're present in some imported modules)

To Reproduce
I did nothing related to Pydantic

Expected behavior
Expected not to receive fatal errors

Screenshots
image

Environments

  • IDE: PyCharm 2021.1.3 (Professional Edition) Build #PY-211.7628.24, built on June 30, 2021
  • OS: macOS Big Sur 11.4 (20F71)
  • Pydantic Version 1.8.2
  • Plugin version 0.3.5

Additional context
Logs:

java.lang.Throwable: Non-idempotent computation: it returns different results when invoked multiple times or on different threads:
  1 != 2
  which is length of [PyTargetExpression: dialect@0] and [PyTargetExpression: dialect@0, PyTargetExpression: dialect@0]

Recomputation gives [Lcom.intellij.psi.ResolveResult;@8c05c37 (class [Lcom.intellij.psi.ResolveResult;) which is equivalent to 'fresh'
Recomputation log:
  Resolving PyQualifiedReference(PyReferenceExpression: dialect,com.jetbrains.python.psi.resolve.PyResolveContext@ed11a5b1) of class com.jetbrains.python.psi.impl.references.PyQualifiedReference
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:161)
	at com.intellij.util.IdempotenceChecker.reportFailure(IdempotenceChecker.java:90)
	at com.intellij.util.IdempotenceChecker.checkEquivalence(IdempotenceChecker.java:77)
	at com.intellij.psi.impl.source.resolve.ResolveCache.cache(ResolveCache.java:322)
	at com.intellij.psi.impl.source.resolve.ResolveCache.resolve(ResolveCache.java:249)
	at com.intellij.psi.impl.source.resolve.ResolveCache.resolve(ResolveCache.java:154)
	at com.intellij.psi.impl.source.resolve.ResolveCache.resolveWithCaching(ResolveCache.java:169)
	at com.intellij.psi.impl.source.resolve.ResolveCache.resolveWithCaching(ResolveCache.java:162)
	at com.jetbrains.python.psi.impl.references.PyReferenceImpl.multiResolve(PyReferenceImpl.java:95)
	at com.jetbrains.python.psi.PyUtil.multiResolveTopPriority(PyUtil.java:514)
	at com.jetbrains.python.codeInsight.typing.PyTypingTypeProvider.tryResolvingWithAliases(PyTypingTypeProvider.java:1383)
	at com.jetbrains.python.codeInsight.typing.PyTypingTypeProvider.tryResolving(PyTypingTypeProvider.java:1372)
	at com.jetbrains.python.codeInsight.typing.PyTypingTypeProvider.resolveToQualifiedNames(PyTypingTypeProvider.java:1438)
	at com.jetbrains.python.codeInsight.typing.PyTypedDictTypeProvider$Companion.isTypedDict(PyTypedDictTypeProvider.kt:42)
	at com.jetbrains.python.codeInsight.typing.PyTypedDictTypeProvider$Companion.getTypedDictTypeForCallee(PyTypedDictTypeProvider.kt:111)
	at com.jetbrains.python.codeInsight.typing.PyTypedDictTypeProvider$Companion.access$getTypedDictTypeForCallee(PyTypedDictTypeProvider.kt:38)
	at com.jetbrains.python.codeInsight.typing.PyTypedDictTypeProvider.getReferenceExpressionType(PyTypedDictTypeProvider.kt:27)
	at com.jetbrains.python.psi.impl.PyReferenceExpressionImpl.getTypeFromProviders(PyReferenceExpressionImpl.java:385)
	at com.jetbrains.python.psi.impl.PyReferenceExpressionImpl.getType(PyReferenceExpressionImpl.java:219)
	at com.jetbrains.python.psi.types.TypeEvalContext.lambda$getType$0(TypeEvalContext.java:180)
	at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:111)
	at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:43)
	at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
	at com.jetbrains.python.psi.types.TypeEvalContext.getType(TypeEvalContext.java:169)
	at com.koxudaxi.pydantic.PydanticKt.getType(Pydantic.kt:123)
	at com.koxudaxi.pydantic.PydanticKt.getPyClassByPyCallExpression(Pydantic.kt:131)
	at com.koxudaxi.pydantic.PydanticKt.getPydanticPyClass(Pydantic.kt:466)
	at com.koxudaxi.pydantic.PydanticInspection$Visitor.inspectPydanticModelCallableExpression(PydanticInspection.kt:84)
	at com.koxudaxi.pydantic.PydanticInspection$Visitor.visitPyCallExpression(PydanticInspection.kt:54)
	at com.jetbrains.python.psi.impl.PyCallExpressionImpl.acceptPyVisitor(PyCallExpressionImpl.java:29)
	at com.jetbrains.python.psi.impl.PyBaseElementImpl.accept(PyBaseElementImpl.java:69)
	at com.intellij.codeInspection.InspectionEngine.acceptElements(InspectionEngine.java:65)
	at com.intellij.codeInspection.InspectionEngine.createVisitorAndAcceptElements(InspectionEngine.java:56)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.runToolOnElements(LocalInspectionsPass.java:320)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$4(LocalInspectionsPass.java:279)
	at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:161)
	at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:153)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$5(LocalInspectionsPass.java:277)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:132)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:121)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$6(LocalInspectionsPass.java:277)
	at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:136)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1096)
	at com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$1(ApplierCompleter.java:92)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:688)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:634)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:64)
	at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:104)
	at com.intellij.concurrency.ApplierCompleter.lambda$compute$0(ApplierCompleter.java:83)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:167)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:178)
	at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:83)
	at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
@koxudaxi
Copy link
Owner

@mahenzon
Thank you for reporting this problem.
I will check the problem.

@koxudaxi
Copy link
Owner

koxudaxi commented Mar 2, 2023

@mahenzon
I'm sorry for my too-late fix.
I have released a new version v0.4.0 in the market
The version dropped unnecessary resolving for an object reference.
It means the update reduces CPU load and fixes unexpected errors.

I closed the PR because the root cause method was removed from the plugin's source code.
Thank you.

@koxudaxi koxudaxi closed this as completed Mar 2, 2023
@mahenzon
Copy link
Author

mahenzon commented Mar 2, 2023

Cool, thank you!

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

No branches or pull requests

2 participants