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

linting: declare methods without self-use static and annotate legitimate methods #264

Merged
merged 7 commits into from Jul 3, 2018

Conversation

Bastian-Krause
Copy link
Member

Fixes this linting warning:

no-self-use (R0201):
Method could be a function. Used when a method doesn’t use its bound instance, and so could be written as a function.

@codecov
Copy link

codecov bot commented Jun 11, 2018

Codecov Report

Merging #264 into master will not change coverage.
The diff coverage is 77.7%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #264   +/-   ##
======================================
  Coverage    54.8%   54.8%           
======================================
  Files         106     106           
  Lines        6264    6264           
======================================
  Hits         3438    3438           
  Misses       2826    2826
Impacted Files Coverage Δ
labgrid/resource/udev.py 48.7% <100%> (ø) ⬆️
labgrid/remote/exporter.py 35.2% <100%> (ø) ⬆️
labgrid/util/agent.py 72.5% <100%> (ø) ⬆️
labgrid/resource/ethernetport.py 25.9% <50%> (ø) ⬆️
labgrid/factory.py 83.8% <66.6%> (ø) ⬆️
labgrid/stepreporter.py 44.4% <66.6%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c798796...884358c. Read the comment docs.

@@ -925,7 +925,7 @@ def create():

def find_role_by_place(config, place):
for role, role_config in config.items():
resources, _ = target_factory.normalize_config(role_config)
resources, _ = target_factory.__class__.normalize_config(role_config)
Copy link
Member

Choose a reason for hiding this comment

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

The class should be unnecessary here. You can use staticmethods on instances as well.

@@ -54,7 +54,7 @@ def test_convert_dict(self):
BarPort:
name: bar
""")
l = target_factory._convert_to_named_list(data)
l = target_factory.__class__._convert_to_named_list(data)
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be necessary here as well.

No "self" is used, so declare it static.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
No "self" is used so declare it static.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
No "self" is used so declare it static.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
…t() static

No "self" is used so declare it static. Avoid importing TargetFactory
and thereby legitimizing its use instead of using the global TargetFactory
instance "target_factory".

Signed-off-by: Bastian Stender <bst@pengutronix.de>
No "self" use is valid here as it is inherited by IMXUSBLoader. "self"
is used there.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
No "self" is used so declare it static. Avoid importing TargetFactory
and thereby legitimizing its use instead of using the global TargetFactory
instance "target_factory".

Signed-off-by: Bastian Stender <bst@pengutronix.de>
These methods are inherited by USBSerialPortExport. "self" is used
there.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
@Bastian-Krause
Copy link
Member Author

Pushed changes:

  • use static methods on instances without __class__ indirection

@jluebbe jluebbe merged commit d2a59e2 into labgrid-project:master Jul 3, 2018
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.

None yet

2 participants