Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Tests formatted as per PEP8 guidelines #227

Merged
merged 4 commits into from
Jan 18, 2019

Conversation

pravarag
Copy link
Contributor

@pravarag pravarag commented Dec 20, 2018

Formatted test scripts for jaeger-client-python as per the PEP8 guidelines for better readability.

@pravarag pravarag changed the title Tests formatted as per PEP8 instructions Tests formatted as per PEP8 guidelines Dec 20, 2018
@black-adder
Copy link
Contributor

Was this done manually or did you run a linter? If the latter, it might be better to add that to the makefile and travis scripts so that the linter can run automatically. Also, I think you have to adjust the rules of the linter as the license headers should be comments, not a string literal.

@pravarag
Copy link
Contributor Author

For now I've done manually only. But adding a linter is a good suggestion. I'll add that surely then...

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Copy link
Member

Choose a reason for hiding this comment

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

copyright header is not a docs string, it should remain as comments,

@yurishkuro
Copy link
Member

not opposed to merging this, but need to address a couple of things:

  • undo changes to the license headers
  • whichever guidelines this is trying to follow need to be enforced automatically by a build, e.g. make lint must fail if guidelines are not observed. Without the automatic verification it's not worth making these changes.

@pravarag
Copy link
Contributor Author

It seems 'flake-8' is already present as a style guiding linter in make file. But still I can see some errors in the code related to PEP-8 format. Can we enforce PEP-8 in .travis.yml so that pep-8 can check the .py files for any violations?

@black-adder
Copy link
Contributor

looks like we already run flake-8 in travis https://github.com/jaegertracing/jaeger-client-python/blob/master/.travis.yml#L33; are we possibly swallowing the errors in travis?

@yurishkuro
Copy link
Member

yurishkuro commented Jan 10, 2019

But still I can see some errors in the code related to PEP-8 format.

@pravarag I don't understand what you mean. There are no errors from flake8:

$ make lint
flake8 jaeger_client crossdock tests
./scripts/check-license.sh

which is why I asked above: when you say "still I can see some errors", which linter are you running?

-- UPDATE --
the reason lint above wasn't failing was because tests were excluded from flake8 config in setup.cfg, so including the directory in the command had no effect

@yurishkuro
Copy link
Member

related #231

@pravarag
Copy link
Contributor Author

@yurishkuro with errors in tests, I meant that code in few of the test files is still not indented as per PEP8. As you have mentioned in #231 , that tests is excluded from flake8 configuration. So, any chance tests will be included in flake8 configuration in near future?

@yurishkuro
Copy link
Member

@pravarag I am now clear on what was happening (I updated my #227 (comment) above). If you would like to finish this PR and address the comments, we will merge it and enforce linting of tests going forward.

@pravarag
Copy link
Contributor Author

pravarag commented Jan 14, 2019

@yurishkuro , I've updated the code with the following
-> In make file, added tests in "lint: "
-> In setup.cfg, removed entry for tests in the exclude list

now, make lint reports PEP8 errors if there are any in jaeger-client, crossdock & tests.
Please review the code.

@codecov
Copy link

codecov bot commented Jan 15, 2019

Codecov Report

Merging #227 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #227   +/-   ##
=======================================
  Coverage   94.59%   94.59%           
=======================================
  Files          25       25           
  Lines        1867     1867           
  Branches      247      247           
=======================================
  Hits         1766     1766           
  Misses         66       66           
  Partials       35       35

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 3f091d4...be99043. Read the comment docs.

@pravarag pravarag force-pushed the master branch 3 times, most recently from 4d4b8f0 to a69311f Compare January 16, 2019 04:39
@@ -13,10 +13,8 @@
# limitations under the License.

from __future__ import absolute_import

import mock
# import mock # noqa: F401
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of commenting, I think we should remove the import if it's not used

import unittest

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep this blank line to separate the standard imports from out own modules

@@ -133,18 +133,19 @@ def test_throttler(self):

def test_for_unexpected_config_entries(self):
with self.assertRaises(Exception):
_ = Config({"unexpected":"value"}, validate=True)
_ = Config({'unexpected': 'value'}, validate=True)
assert _
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you do this same as you did for other cases? i.e. just call Config({"unexpected":"value"}, validate=True)

Copy link
Member

Choose a reason for hiding this comment

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

what is the purpose of adding assert, since it's never expected to be reached?

@@ -1,13 +1,13 @@
# Copyright (c) 2016-2018 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the 'License');
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this

Copy link
Member

Choose a reason for hiding this comment

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

please do not change license headers, they are standard and not subject to code guidelines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I'll revert back the changes..

# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# distributed under the License is distributed on an 'AS IS' BASIS,
Copy link
Contributor

Choose a reason for hiding this comment

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

This as well

@@ -12,7 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
Copy link
Contributor

Choose a reason for hiding this comment

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

This as well?

@@ -1,18 +1,19 @@
from __future__ import division
# Copyright (c) 2016-2018 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the 'License');
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# distributed under the License is distributed on an 'AS IS' BASIS,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

@@ -1,13 +1,13 @@
# Copyright (c) 2016 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the 'License');
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# distributed under the License is distributed on an 'AS IS' BASIS,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

@@ -1,4 +1,5 @@
from __future__ import print_function
Copy link
Member

Choose a reason for hiding this comment

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

the import should go after standard license header

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll change this as well..

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

lgtm, some small corrections, and please do not change the license headers

Changes for including flake8 in tests folder

Signed-off-by: pravar <pravarag@gmail.com>
@pravarag
Copy link
Contributor Author

@yurishkuro, I've done the corrections and reverted back the changes to license headers. Please review.

@ghost ghost assigned yurishkuro Jan 18, 2019
@ghost ghost added the review label Jan 18, 2019
@yurishkuro
Copy link
Member

tests/test_utils.py:80:1: E302 expected 2 blank lines, found 1
tests/test_utils.py:82:49: W292 no newline at end of file

@pravarag
Copy link
Contributor Author

It seems these below lines were recently added in test_utils.py

def test_get_local_ip_by_socket_does_not_blow_up():
    import jaeger_client.utils
    jaeger_client.utils.get_local_ip_by_socket()

That's why the build failed
Pulled the latest changes and committed the code.

@yurishkuro yurishkuro merged commit 0ce73e3 into jaegertracing:master Jan 18, 2019
@ghost ghost removed the review label Jan 18, 2019
@yurishkuro
Copy link
Member

Nicely done!

@pravarag
Copy link
Contributor Author

Thanks!! will continue contributing :-)

@yurishkuro
Copy link
Member

Much appreciated (#235 - wink, wink).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants