-
Notifications
You must be signed in to change notification settings - Fork 59
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
Replaced all instances of outdated type annotations (List, Dict, etc.…) #1081
Replaced all instances of outdated type annotations (List, Dict, etc.…) #1081
Conversation
…) with the current built-in types (list, dict, etc.) .
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.
@CulmoneY okay good work, though overall you were a bit too broad with your find-and-replace (see inline comments).
In addition to the comments I left inline, I have two additional comments:
- You'll need to update your branch since I merged in @Raine-Yang-UofT's PR (see my message on Slack). There will be merge conflicts, so you have a good opportunity to practice resolving those.
- Update the Changelog. This is an internal change.
@@ -3,15 +3,15 @@ | |||
# Default max amount of messages for reporter to display. | |||
pyta-number-of-messages = 10 | |||
|
|||
# Set whether the default error messages by pylint should be overwritten by python TA's custom messages | |||
# set whether the default error messages by pylint should be overwritten by python TA's custom messages |
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.
Don't change this file
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.
I'm not sure why you marked this comment as resolved; perhaps you meant to make this change, but either forgot or did not commit the change. Either way, please ensure that you double-check your work before resolving my comments, as I don't want to repeat comments.
tests/test_messages_config/test_no_user_config_no_pyta_overwrite.pylintrc
Outdated
Show resolved
Hide resolved
@CulmoneY oh sorry I realized you hadn't yet requested a review, so I may have been a bit premature! Well, keep working :) |
for more information, see https://pre-commit.ci
python_ta/transforms/setendings.py
Outdated
@@ -478,7 +478,7 @@ def end_setter_from_source(source_code, pred, only_consumables=False): | |||
def set_endings_from_source(node): | |||
# Tuple nodes have an end_col_offset that includes the end paren, | |||
# but their col_offset does not include the start paren. | |||
# To address this, we override the Tuple node's end_col_offset. | |||
# To address this, we override the tuple node's end_col_offset. |
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.
revert this change
python_ta/z3/z3_parser.py
Outdated
) -> List[z3.ExprRef]: | ||
"""Convert an astroid List, Set, Tuple node to a list of z3 expressions.""" | ||
) -> list[z3.ExprRef]: | ||
"""Convert an astroid list, Set, tuple node to a list of z3 expressions.""" |
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.
Revert these changes
tests/test_cfg/test_cfg_generator.py
Outdated
@@ -43,7 +43,7 @@ def create_cfg_funcs_only(): | |||
|
|||
This fixture specifies that cfgs will only be created for functions. | |||
""" | |||
# Setup: store the paths of the files being used/created | |||
# setup: store the paths of the files being used/created |
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.
revert this change
@@ -3,15 +3,15 @@ | |||
# Default max amount of messages for reporter to display. | |||
pyta-number-of-messages = 10 | |||
|
|||
# Set whether the default error messages by pylint should be overwritten by python TA's custom messages | |||
# set whether the default error messages by pylint should be overwritten by python TA's custom messages |
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.
I'm not sure why you marked this comment as resolved; perhaps you meant to make this change, but either forgot or did not commit the change. Either way, please ensure that you double-check your work before resolving my comments, as I don't want to repeat comments.
…oring_type_annotations
@@ -25,7 +26,7 @@ class Person: | |||
|
|||
age: int | |||
name: str | |||
fav_foods: List[str] | |||
fav_foods: list[str] |
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.
Okay so the tests on 3.8 are failing, and not just because of the flaky test we previously discussed. I realized that because 3.8 doesn't support the newer type annotations, we can't change these type annotations *for functions and classes that are used for contract-checking testing. This includes the functions/classes in this file and other files under tests/test_contracts
. Please revert those changes.
Pull Request Test Coverage Report for Build 11047801951Details
💛 - Coveralls |
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.
@CulmoneY it's great to see that the tests are passing. I left a few more comments, but also it appears you haven't addressed all of the comments I left in my previous review. You should go through each of these carefully; one strategy to keep track of your progress is to use an emoji reaction to indicate when you've fixed (and committed) a change for a particular comment.
Don't resolve any comments until you've pushed your changes and verified that the issue is actually fixed (there was at least one instance I saw where you had resolved a comment but hadn't actually made the corresponding change).
tests/test_subclass_contracts.py
Outdated
@@ -9,6 +11,7 @@ class Employee: | |||
""" | |||
Represents an employee | |||
|
|||
Representation Invariants: |
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.
delete this line
@@ -14,7 +14,6 @@ def test_type_is_assigned_for_function(self): | |||
src = """ | |||
from typing import List | |||
|
|||
|
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.
revert this change
Hi David, All the requested changes have been implemented. I double-checked everything to ensure that there are no unnecessary or incomplete modifications. However, I would like to apologize for any inconvenience caused by premature reviews. I converted my PR from draft status to run the tests, which is why some of your requested corrections weren't implemented at the time. Moving forward, I’ll be more mindful to avoid this and ensure that my PR is fully ready before requesting a review. Thank you for your understanding, and I appreciate your time and feedback. |
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.
@CulmoneY looks great! For future reference, you can unmark a PR as draft in order to trigger the CI tests, and that's a separate actions from "requesting a review" from me (the latter is a separate action on GitHub). This lets you run the CI tests without yet asking for me to review it.
Proposed Changes
Updated the PythonTA codebase to use modern type annotations. Specifically, I replaced
List
withlist
,Dict
withdict
,Set
withset
, andTuple
withtuple
. I addressed the following two requirements:from __future__ import annotations
to the top of each file where these type annotations are used, if it wasn't present already.List
,Dict
,Set
, andTuple
to clean up the codebase.Type of Change
(Write an
X
or a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]
into a[x]
in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request: