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

[FBcode->GH] [codemod] Replace hasattr with getattr in pytorch/vision/test/test_transforms_tensor.py #7553

Merged
merged 2 commits into from
May 3, 2023

Conversation

NicolasHug
Copy link
Member

@NicolasHug NicolasHug commented May 2, 2023

Summary:
The pattern

X.Y if hasattr(X, "Y") else Z

can be replaced with

getattr(X, "Y", Z)

The getattr function gives more succinct code than the hasattr function. Please use it when appropriate.

This diff is very low risk. Green tests indicate that you can safely Accept & Ship.

Differential Revision: D44886862

fbshipit-source-id: 4e6b69f475d1fe6d2e13012850fde81aae0745ad

cc @pmeier

…ansforms_tensor.py

Summary:
The pattern
```
X.Y if hasattr(X, "Y") else Z
```
can be replaced with
```
getattr(X, "Y", Z)
```

The [getattr](https://www.w3schools.com/python/ref_func_getattr.asp) function gives more succinct code than the [hasattr](https://www.w3schools.com/python/ref_func_hasattr.asp) function. Please use it when appropriate.

**This diff is very low risk. Green tests indicate that you can safely Accept & Ship.**

Differential Revision: D44886862

fbshipit-source-id: 4e6b69f475d1fe6d2e13012850fde81aae0745ad
@pytorch-bot
Copy link

pytorch-bot bot commented May 2, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/7553

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 29 New Failures, 1 Unrelated Failure

As of commit 8baa1f1:

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base 020513d:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Stamp

@NicolasHug NicolasHug merged commit 8fa3aa5 into pytorch:main May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants