Skip to content

Commit

Permalink
test: add additional tests for info
Browse files Browse the repository at this point in the history
  • Loading branch information
vidhanio committed Jun 23, 2023
1 parent 1c3fcc6 commit 9fa26d0
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/test/python_tests/test_data/sample1/sample.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import sys

print(x)

class Foo:
def __eq__(self, other: "Foo") -> bool:
return True
102 changes: 99 additions & 3 deletions src/test/python_tests/test_linting.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,39 @@ def _log_handler(params):
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-name-defined"
},
"source": "Mypy",
}
},
{
"range": {
"start": {"line": 5, "character": 21},
"end": {"line": 5, "character": 32},
},
"message": 'Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"',
"severity": 1,
"code": "override",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-override"
},
"source": "Mypy",
},
{
"range": {
"start": {"line": 5, "character": 21},
"end": {"line": 5, "character": 32},
},
"message": """This violates the Liskov substitution principle
See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
It is recommended for "__eq__" to work with arbitrary objects, for example:
def __eq__(self, other: object) -> bool:
if not isinstance(other, Foo):
return NotImplemented
return <logic to compare two Foo instances>""",
"severity": 3,
"code": "note",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides"
},
"source": "Mypy",
},
],
}

Expand Down Expand Up @@ -124,7 +156,39 @@ def _log_handler(params):
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-name-defined"
},
"source": "Mypy",
}
},
{
"range": {
"start": {"line": 5, "character": 21},
"end": {"line": 5, "character": 32},
},
"message": 'Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"',
"severity": 1,
"code": "override",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-override"
},
"source": "Mypy",
},
{
"range": {
"start": {"line": 5, "character": 21},
"end": {"line": 5, "character": 32},
},
"message": """This violates the Liskov substitution principle
See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
It is recommended for "__eq__" to work with arbitrary objects, for example:
def __eq__(self, other: object) -> bool:
if not isinstance(other, Foo):
return NotImplemented
return <logic to compare two Foo instances>""",
"severity": 3,
"code": "note",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides"
},
"source": "Mypy",
},
],
}

Expand Down Expand Up @@ -246,7 +310,39 @@ def _log_handler(params):
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-name-defined"
},
"source": "Mypy",
}
},
{
"range": {
"start": {"line": 5, "character": 21},
"end": {"line": 5, "character": 32},
},
"message": 'Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"',
"severity": 1,
"code": "override",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-override"
},
"source": "Mypy",
},
{
"range": {
"start": {"line": 5, "character": 21},
"end": {"line": 5, "character": 32},
},
"message": """This violates the Liskov substitution principle
See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
It is recommended for "__eq__" to work with arbitrary objects, for example:
def __eq__(self, other: object) -> bool:
if not isinstance(other, Foo):
return NotImplemented
return <logic to compare two Foo instances>""",
"severity": 3,
"code": "note",
"codeDescription": {
"href": "https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides"
},
"source": "Mypy",
},
],
}

Expand Down

0 comments on commit 9fa26d0

Please sign in to comment.