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 part of #12912: Changes deprecated python methods #14506

Merged
merged 19 commits into from
Jan 14, 2022

Conversation

IamEzio
Copy link
Contributor

@IamEzio IamEzio commented Dec 28, 2021

Overview

  1. This PR fixes part of Fix pylint problems #12912 .
  2. This PR does the following: Removes following deprecated python methods -

Screenshot from 2021-12-29 00-02-50

Essential Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The linter/Karma presubmit checks have passed locally on your machine.
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)
    • This lets reviewers restart your CircleCI tests for you.
  • The PR is made from a branch that's not called "develop".

Proof that changes are correct

Screenshot from 2021-12-28 22-23-47

PR Pointers

  • Make sure to follow the instructions for making a code change.
  • Oppiabot will notify you when you don't add a PR_CHANGELOG label. If you are unable to do so, please @-mention a code owner (who will be in the Reviewers list), or ask on Gitter.
  • For what code owners will expect, see the Code Owner's wiki page.
  • Make sure your PR follows conventions in the style guide, otherwise this will lead to review delays.
  • Never force push. If you do, your PR will be closed.
  • Oppiabot can assign anyone for review/help if you leave a comment like the following: "{{Question/comment}} @{{reviewer_username}} PTAL"
  • Some of the e2e tests are flaky, and can fail for reasons unrelated to your PR. We are working on fixing this, but in the meantime, if you need to restart the tests, please check the "If your build fails" wiki page.

@oppiabot
Copy link

oppiabot bot commented Dec 28, 2021

Hi @vojtechjelinek, @seanlip -- could one of you please add the appropriate changelog label to this pull request? Thanks!

Copy link
Member

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks! Left two comments.

CHANGELOG Outdated Show resolved Hide resolved
Comment on lines 3676 to 3678
sig = inspect.signature(self._func)

args_dict = sig.bind_partial(*args, **kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

getcallargs() was also deprecated in the new python version and was showing the same error as other deprecated methods when pylint ran.
Screenshot from 2021-12-29 22-59-19

Copy link
Member

Choose a reason for hiding this comment

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

Okay, could you then do

Suggested change
sig = inspect.signature(self._func)
args_dict = sig.bind_partial(*args, **kwargs)
sig = inspect.signature(self._func)
args_dict = sig.bind_partial(*args, **kwargs)

and add an explanatory comment above it explaining what this code does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, but I made a mistake here as this would not be the correct way to replace inspect.getcallargs( ). The method getcallargs() returns a dict while bind_partial( ) returns BoundArguments. This test is failing due to this issue.

I searched for the valid solution of this issue but could not find any satisfactory solution except these lines of code which use bind( ) to return dict.
Screenshot from 2022-01-03 17-11-57

However I am not sure of this and open to suggestions.
This error didn't show up in my localmachine. I am sorry if I caused any troubles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@vojtechjelinek Can you please help here?

Copy link
Member

Choose a reason for hiding this comment

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

@IamEzio Hey look at this https://docs.python.org/3/library/inspect.html#inspect.BoundArguments, the structure of BoundArguments is explained there, from this you should be able to change the code.

@oppiabot
Copy link

oppiabot bot commented Dec 29, 2021

Unassigning @vojtechjelinek since the review is done.

@oppiabot
Copy link

oppiabot bot commented Dec 29, 2021

Hi @IamEzio, it looks like some changes were requested on this pull request by @vojtechjelinek. PTAL. Thanks!

@IamEzio
Copy link
Contributor Author

IamEzio commented Dec 29, 2021

@vojtechjelinek PTAL! Thanks

@oppiabot oppiabot bot assigned vojtechjelinek and unassigned IamEzio Dec 29, 2021
Copy link
Contributor

@iamprayush iamprayush left a comment

Choose a reason for hiding this comment

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

LGTM!

@oppiabot
Copy link

oppiabot bot commented Jan 10, 2022

Unassigning @iamprayush since they have already approved the PR.

@oppiabot oppiabot bot added the PR: LGTM label Jan 10, 2022
@oppiabot
Copy link

oppiabot bot commented Jan 10, 2022

Hi @DubeySandeep, this PR is ready to be merged. Author of this PR does not have permissions to merge this PR. Before you merge it, please make sure that there are no pending comments that require action from the author's end. Thanks!

@oppiabot
Copy link

oppiabot bot commented Jan 10, 2022

Hi @IamEzio. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks!

@oppiabot
Copy link

oppiabot bot commented Jan 11, 2022

Hi @IamEzio, there is a new change in develop which needs to be in your PR. Please update your branch with the latest changes in develop. For instructions, refer to this link. Thanks!

@DubeySandeep DubeySandeep enabled auto-merge (squash) January 11, 2022 19:36
@DubeySandeep
Copy link
Member

@vojtechjelinek Can you please reply on this thread?

@oppiabot
Copy link

oppiabot bot commented Jan 13, 2022

Hi @IamEzio. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks!

@IamEzio IamEzio removed their assignment Jan 13, 2022
@IamEzio
Copy link
Contributor Author

IamEzio commented Jan 13, 2022

@DubeySandeep PTAL! I refactored the code which solved this failing backend test.

@DubeySandeep DubeySandeep merged commit 2a115bb into oppia:develop Jan 14, 2022
@IamEzio IamEzio deleted the pylint-rule branch January 14, 2022 16:40
DiptoChakrabarty added a commit to DiptoChakrabarty/oppia that referenced this pull request Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants