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 NullPointerException in PydanticTypeCheckerInspection.kt #362

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<idea-plugin url="https://github.com/koxudaxi/pydantic-pycharm-plugin" require-restart="true">
<id>com.koxudaxi.pydantic</id>
<name>Pydantic</name>
<version>0.3.5</version>
<version>0.3.6</version>
<vendor email="koaxudai@gmail.com">Koudai Aono @koxudaxi</vendor>
<change-notes><![CDATA[
<h2>version 0.3.6</h2>
<p>BugFixes</p>
<ul>
<li>Fix NullPointerException in PydanticTypeCheckerInspection.kt [#362]</li>
</ul>
<h2>version 0.3.5</h2>
<p>Features</p>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion src/com/koxudaxi/pydantic/PydanticTypeCheckerInspection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class PydanticTypeCheckerInspection : PyTypeCheckerInspection() {
for ((argument, parameter) in PyCallExpressionHelper.getRegularMappedParameters(mappedParameters)) {
val expected = parameter.getArgumentType(myTypeEvalContext)
val promotedToLiteral = promoteToLiteral(argument, expected, myTypeEvalContext)
val actual = promotedToLiteral ?: myTypeEvalContext.getType(argument)!!
val actual = promotedToLiteral ?: myTypeEvalContext.getType(argument)
val strictMatched = matchParameterAndArgument(expected, actual, substitutions)
val strictResult = AnalyzeArgumentResult(expected, actual, strictMatched)
if (!strictResult.isMatched) {
Expand Down
11 changes: 11 additions & 0 deletions testData/typecheckerinspection/acceptableType.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@ class A(BaseModel):

A(a=str('123'))
A(<weak_warning descr="Field is of type 'str', 'int' is set as an acceptable type in pyproject.toml">a=int(123)</weak_warning>)

def get_unknown_type_value():
raise Exception()

A(a=get_unknown_type_value())
A(<warning descr="Expected type 'str', got 'None' instead">a=None</warning>)

class B:
pass

A(<warning descr="Expected type 'str', got 'B' instead">a=B()</warning>)