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

Typehints: Adding type hints to the parameters and fixtures of test_messages.py #1373

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

abdulmoiz37
Copy link
Collaborator

@abdulmoiz37 abdulmoiz37 commented Apr 8, 2023

I Have Opened this PR for the #1337 but dont know why the linting tests are failing @neiljp. Plz do have a review of this

@zulipbot zulipbot added the size: L [Automatic label added by zulipbot] label Apr 8, 2023
@abdulmoiz37
Copy link
Collaborator Author

abdulmoiz37 commented Apr 8, 2023

@zulipbot add "PR needs review"

@neiljp
Copy link
Collaborator

neiljp commented Apr 9, 2023

@abdulmoiz37 I'm taking a longer look, but just a note that the linting is likely simply that we use tools to autoformat the code (black, isort), but we don't enforce that individuals run them on each commit. See https://github.com/zulip/zulip-terminal#auto-formatting-code.

Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulmoiz37 Thanks for giving this a go! I'd recommend reviewing other test files a little when doing this, side by side, for where the types go.

Some of the other types will get checked more automatically when they are in the right places, as I noted inline.

@@ -25,12 +28,12 @@

class TestMessageBox:
@pytest.fixture(autouse=True)
def mock_external_classes(self, mocker, initial_index):
def mock_external_classes(self, mocker: MockerFixture, initial_index: int) -> Any:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial_index is a common fixture. See conftest.py for a lot of these.

I suspect this should return None.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay,No problem I will check edit this and create a new commit

self.model = mocker.MagicMock()
self.model.index = initial_index

@pytest.mark.parametrize(
"message_type, set_fields",
"message_type: str, set_fields:List[Tuple[str, Any]]",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the other files which have been annotated - these belong in the def test_init(...) part of the function.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the lines you changed here should not be updated in the PR - pytest fails due to this. The changes should be in the other part, which I see you've changed in some locations.

Copy link
Collaborator Author

@abdulmoiz37 abdulmoiz37 Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neiljp Do you want me remove this latest commit and come up with a new single commit for all the changes in this PR?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://github.com/zulip/zulip-terminal#structuring-commits---speeding-up-reviews-merging--development

You can add commits as you like, and I can give limited feedback based on the overall changes at an earlier stage. However, as per the above link, the easier it is to read the better. One commit per file with type annotations added should be fine.

@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback area: tests labels Apr 9, 2023
@neiljp
Copy link
Collaborator

neiljp commented Apr 9, 2023

Also note that we don't use merge commits so these will need removing, though I'm aware you wanted early feedback at this time 👍

@zulipbot zulipbot added size: XL [Automatic label added by zulipbot] and removed size: L [Automatic label added by zulipbot] labels Apr 10, 2023
@abdulmoiz37
Copy link
Collaborator Author

abdulmoiz37 commented Apr 10, 2023

@neiljp Sir ,If the above commit Satisfies the Type hints test_messages.py and annotations should i also add this in model/test_model.py and the
ui/test_ui_tools.py so can i open sepearte PR's to the other test files?

@neiljp
Copy link
Collaborator

neiljp commented Apr 11, 2023

@abdulmoiz37 Other PRs would be fine, though I'd wait for this to be complete first, to ensure you understand the requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: tests PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants