Skip to content

Commit

Permalink
chore(linting): bump pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKevJames committed Mar 20, 2019
1 parent 2700e3e commit f32785c
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 41 deletions.
20 changes: 17 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.2.2
rev: v2.3.1
hooks:
- id: pylint
args:
Expand All @@ -44,13 +44,13 @@ repos:
hooks:
- id: remove-tabs
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.3.5
rev: v1.4.0
hooks:
- id: reorder-python-imports
args: [--py26-plus]
files: coveralls/.*
- repo: https://github.com/asottile/yesqa
rev: v0.0.9
rev: v0.0.10
hooks:
- id: yesqa
files: coveralls/.*
Expand All @@ -59,6 +59,20 @@ repos:
hooks:
- id: autopep8
files: coveralls/.*
- repo: https://github.com/PyCQA/pydocstyle
rev: 792b8d92 # TODO: >3.0.0
hooks:
- id: pydocstyle
args:
- --ignore=D1,D203,D205,D212,D400,D401,D404
files: coveralls/.*
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.7
hooks:
- id: flake8
args:
- --ignore=E501,W503,F811,F821
files: coveralls/.*
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.2.0
hooks:
Expand Down
12 changes: 6 additions & 6 deletions coveralls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class Coveralls(object):
config_filename = '.coveralls.yml'

def __init__(self, token_required=True, service_name=None, **kwargs):
""" Coveralls!
"""
* repo_token
The secret token for your repository, found at the bottom of your
repository's page on Coveralls.
Expand Down Expand Up @@ -166,7 +165,6 @@ def merge(self, path):
self.create_data(extra)

def wear(self, dry_run=False):
""" run! """
try:
json_string = self.create_report()
except coverage.CoverageException as e:
Expand Down Expand Up @@ -215,8 +213,10 @@ def save_report(self, file_path):
report_file.write(report)

def create_data(self, extra=None):
""" Generate object for api.
Example json:
r"""
Generate object for api.
Example json:
{
"service_job_id": "1234567890",
"service_name": "travis-ci",
Expand Down Expand Up @@ -264,7 +264,7 @@ def get_coverage(self):

@staticmethod
def debug_bad_encoding(data):
""" Let's try to help user figure out what is at fault """
"""Let's try to help user figure out what is at fault."""
at_fault_files = set()
for source_file_data in data['source_files']:
for value in source_file_data.values():
Expand Down
3 changes: 2 additions & 1 deletion coveralls/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Publish coverage results online via coveralls.io
"""
Publish coverage results online via coveralls.io
Puts your coverage results on coveralls.io for everyone to see.
Expand Down
22 changes: 11 additions & 11 deletions coveralls/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def gitlog(fmt):


def git_info():
""" A hash of Git data that can be used to display more information to
users.
"""
A hash of Git data that can be used to display more information to users.
Example:
Example:
"git": {
"head": {
"id": "5e837ce92220be64821128a70f6093f836dd2c05",
Expand All @@ -56,14 +56,14 @@ def git_info():
}
"""
try:
branch = (os.environ.get('APPVEYOR_REPO_BRANCH') or
os.environ.get('BUILDKITE_BRANCH') or
os.environ.get('CI_BRANCH') or
os.environ.get('CIRCLE_BRANCH') or
os.environ.get('GIT_BRANCH') or
os.environ.get('TRAVIS_BRANCH') or
os.environ.get('BRANCH_NAME') or
run_command('git', 'rev-parse', '--abbrev-ref', 'HEAD'))
branch = (os.environ.get('APPVEYOR_REPO_BRANCH')
or os.environ.get('BUILDKITE_BRANCH')
or os.environ.get('CI_BRANCH')
or os.environ.get('CIRCLE_BRANCH')
or os.environ.get('GIT_BRANCH')
or os.environ.get('TRAVIS_BRANCH')
or os.environ.get('BRANCH_NAME')
or run_command('git', 'rev-parse', '--abbrev-ref', 'HEAD'))
head = {
'id': gitlog('%H'),
'author_name': gitlog('%aN'),
Expand Down
37 changes: 19 additions & 18 deletions coveralls/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@


class CoverallReporter(Reporter):
""" Custom coverage.py reporter for coveralls.io
"""
"""Custom coverage.py reporter for coveralls.io"""

def __init__(self, *args, **kwargs):
self.source_files = []
super(CoverallReporter, self).__init__(*args, **kwargs)

def report(self, morfs=None):
""" Generate a part of json report for coveralls
"""
Generate a part of json report for coveralls
`morfs` is a list of modules or filenames.
`outfile` is a file object to write the json to.
Expand Down Expand Up @@ -69,14 +69,14 @@ def report(self, morfs=None):

@staticmethod
def get_hits(line_num, analysis):
""" Source file stats for each line.
* A positive integer if the line is covered,
representing the number of times the line is hit during the test
suite.
* 0 if the line is not covered by the test suite.
* null to indicate the line is not relevant to code coverage
(it may be whitespace or a comment).
"""
Source file stats for each line.
* A positive integer if the line is covered, representing the number
of times the line is hit during the test suite.
* 0 if the line is not covered by the test suite.
* null to indicate the line is not relevant to code coverage (it may
be whitespace or a comment).
"""
if line_num in analysis.missing:
return 0
Expand All @@ -88,13 +88,14 @@ def get_hits(line_num, analysis):

@staticmethod
def get_arcs(analysis):
""" Hit stats for each branch.
"""
Hit stats for each branch.
Returns a flat list where every four values represent a branch:
1. line-number
2. block-number (not used)
3. branch-number
4. hits (we only get 1/0 from coverage.py)
Returns a flat list where every four values represent a branch:
1. line-number
2. block-number (not used)
3. branch-number
4. hits (we only get 1/0 from coverage.py)
"""
if not analysis.has_arcs():
return None
Expand All @@ -113,7 +114,7 @@ def get_arcs(analysis):
return branches

def parse_file(self, cu, analysis):
""" Generate data for single file """
"""Generate data for single file"""
if hasattr(analysis, 'parser'):
filename = cu.file_locator.relative_filename(cu.filename)
source_lines = analysis.parser.lines
Expand Down
6 changes: 4 additions & 2 deletions tests/api/configuration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def test_appveyor_no_config(self):

@mock.patch.dict(os.environ, {'BUILDKITE': 'True',
'BUILDKITE_JOB_ID': '1234567',
'BUILDKITE_PULL_REQUEST': '1234'}, clear=True)
'BUILDKITE_PULL_REQUEST': '1234'},
clear=True)
def test_buildkite_no_config(self):
cover = Coveralls(repo_token='xxx')
assert cover.config['service_name'] == 'buildkite'
Expand All @@ -89,7 +90,8 @@ def test_buildkite_no_config(self):

@mock.patch.dict(os.environ, {'BUILDKITE': 'True',
'BUILDKITE_JOB_ID': '1234567',
'BUILDKITE_PULL_REQUEST': 'false'}, clear=True)
'BUILDKITE_PULL_REQUEST': 'false'},
clear=True)
def test_buildkite_no_config_no_pr(self):
cover = Coveralls(repo_token='xxx')
assert cover.config['service_name'] == 'buildkite'
Expand Down

0 comments on commit f32785c

Please sign in to comment.