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

chore: fix code quality issues #1940

Merged
merged 2 commits into from
Feb 12, 2021
Merged

chore: fix code quality issues #1940

merged 2 commits into from
Feb 12, 2021

Conversation

withshubh
Copy link
Contributor

@withshubh withshubh commented Feb 7, 2021

Description

Hi 👋 I ran the DeepSource static analyzer on the forked copy of this repo and found some interesting code quality issues. This PR fixes a few of them.

Summary of changes

  • Remove length check in favour of truthiness of the object
  • Remove unnecessary use of comprehension
  • Use literal syntax instead of function calls to create data structure
  • added .deepsource.toml file
  • Merge isinstance calls

@cla-bot
Copy link

cla-bot bot commented Feb 7, 2021

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @withshubh on file. In order for us to review and merge your code, please start the CLA process at https://determined.ai/cla.

Copy link
Member

@rb-determined-ai rb-determined-ai left a comment

Choose a reason for hiding this comment

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

Thank you for offering these improvements to our project! You will have to sign a cla agreement before the PR will be accepted, which is a process you can start here.

The changes from dictionary comprehension to dict() look good.

Please also rename the PR to be chore: ... rather than perf: ..., as the changes proposed will not be any measurable performance impact within our project. The computationally expensive parts of our project are all deep-learning related and would dwarf any performance impact from an extra dictionary comprehension or len() call.

.deepsource.toml Outdated
@@ -0,0 +1,14 @@
version = 1
Copy link
Member

Choose a reason for hiding this comment

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

We appreciate the config, but we are pretty happy with our current static analysis tooling. Please omit this file from the PR.

@@ -164,7 +164,7 @@ def _write_store(self) -> None:
self._create_det_path_if_necessary()
cache_path = self._get_token_cache_path()
store = {}
if self._tokens is not None and len(self._tokens):
Copy link
Member

Choose a reason for hiding this comment

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

Honestly, I think because we use mypy, using on if len(thing): is superior to depending on the truthiness of if thing: because the truthiness test will sometimes hide bugs from mypy if you e.g. change thing to/from Optional[ThingType]. So I'd prefer that these sorts of changes be omitted.

(also if we were going to depend on the truthiness test, the proposed edit is redundant anyway)

@withshubh withshubh changed the title perf: fix code quality issues chore: fix code quality issues Feb 11, 2021
@withshubh withshubh marked this pull request as draft February 11, 2021 05:01
@cla-bot
Copy link

cla-bot bot commented Feb 11, 2021

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @deepsourcebot, @deepsource-autofix[bot], @withshubh on file. In order for us to review and merge your code, please start the CLA process at https://determined.ai/cla.

@cla-bot
Copy link

cla-bot bot commented Feb 11, 2021

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @withshubh on file. In order for us to review and merge your code, please start the CLA process at https://determined.ai/cla.

1 similar comment
@cla-bot
Copy link

cla-bot bot commented Feb 11, 2021

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @withshubh on file. In order for us to review and merge your code, please start the CLA process at https://determined.ai/cla.

@withshubh withshubh marked this pull request as ready for review February 11, 2021 06:44
@cla-bot
Copy link

cla-bot bot commented Feb 11, 2021

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @withshubh on file. In order for us to review and merge your code, please start the CLA process at https://determined.ai/cla.

Copy link
Member

@rb-determined-ai rb-determined-ai left a comment

Choose a reason for hiding this comment

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

These changes look great, thank you! We got your signed CLA and I'll make sure this lands tomorrow.

Thank you very much for your contribution!

@withshubh
Copy link
Contributor Author

@rb-determined-ai 👋

I have -

  • Signed and e-mailed the CLA
  • removed .deepsource.toml file
  • reverted fix Remove length check in favour of truthiness of the object
  • pushed a new commit - Merge isinstance calls

Please review 💖

@rb-determined-ai
Copy link
Member

@cla-bot[bot] check

@cla-bot cla-bot bot added the cla-signed label Feb 11, 2021
@cla-bot
Copy link

cla-bot bot commented Feb 11, 2021

The cla-bot has been summoned, and re-checked this pull request!

@rb-determined-ai
Copy link
Member

@withshubh Your cla bot is good, but I think you are failing the linting step. You can test it yourself locally by running make -C common check, and so you should be able to fix it and verify your fix locally if you would like.

Remove unnecessary use of comprehension

Use literal syntax instead of function calls to create data structure

Merge `isinstance` calls
Copy link
Member

@rb-determined-ai rb-determined-ai left a comment

Choose a reason for hiding this comment

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

Hey, I thought you had removed the .deepsorce.toml file? I see it here again after the latest commit.

@withshubh
Copy link
Contributor Author

Hey, I thought you had removed the .deepsorce.toml file? I see it here again after the latest commit.

My bad. I pushed it by mistake from my local clone.
Deleted. 💖

@rb-determined-ai
Copy link
Member

Thank you @withshubh, I will approve and merge this change after CI passes.

@withshubh
Copy link
Contributor Author

@rb-determined-ai
Also, I would really appreciate it if you could drop any suggestion on what we can do better to onboard you (or Determined-ai) on DeepSource in the future. :)

@rb-determined-ai
Copy link
Member

@withshubh I think you have done a fine job at dev outreach! Honestly I was impressed you followed up after the initial PR review. But the fact is that we are just satisfied with what we have right now, and that our team is already comfortable with.

@rb-determined-ai rb-determined-ai merged commit aef46c7 into determined-ai:master Feb 12, 2021
@dannysauer dannysauer added this to the 0.14.2 milestone Feb 6, 2024
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.

3 participants