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
[SPARK-40693][CONNECT] mypy complains accessing the variable defined in the class method. #38139
Conversation
Another way to fix is to define the
|
Here is the build job: https://github.com/amaliujia/spark/actions/runs/3201556386 |
R: @HyukjinKwon |
which mypy version do you use BTW? It's interesting that they all pass in CI. |
I just used I don't think I have installed mypy by myself. |
@@ -57,5 +57,7 @@ def __getattr__(self, item: str) -> Any: | |||
class PlanOnlyTestFixture(unittest.TestCase): | |||
@classmethod | |||
def setUpClass(cls: Any) -> None: | |||
cls.connect = MockRemoteSession() | |||
cls._connect = MockRemoteSession() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cls._connect = MockRemoteSession() | |
cls.connect = MockRemoteSession() |
cls.tbl_name = f"tbl{uuid.uuid4()}".replace("-", "") | ||
|
||
connect: "MockRemoteSession" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this type hint under class PlanOnlyTestFixture
(see https://github.com/apache/spark/blob/master/python/pyspark/sql/tests/test_connect_basic.py#L34)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah sure looks like we want to keep with the existing styple.
Merged to master. |
What changes were proposed in this pull request?
For SparkConnectTestsPlanOnly, those unit tests access the mock remote session by
self.connect
, how mypy complains in aserror: "SparkConnectTestsPlanOnly" has no attribute "connect" [attr-defined]
Why are the changes needed?
Fix mypy.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Mypy.