Skip to content

Commit

Permalink
Merge pull request #3551 from rtfd/humitos/lint/fix
Browse files Browse the repository at this point in the history
Fix Travis lint issue
  • Loading branch information
ericholscher authored Jan 26, 2018
2 parents 0fb3574 + 590bc41 commit 7be1b80
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 38 deletions.
1 change: 1 addition & 0 deletions prospector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pylint:
max-line-length: 100
disable:
- logging-format-interpolation
- inconsistent-return-statements

mccabe:
run: false
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def is_authenticated(self, request, **kwargs):


class EnhancedModelResource(ModelResource):
def obj_get_list(self, request=None, *_, **kwargs): # pylint: disable=arguments-differ
def obj_get_list(self, request=None, *_, **kwargs): # noqa
"""
A ORM-specific implementation of ``obj_get_list``.
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/builds/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Meta(object):
'largest',
)

def __init__(self, instance=None, *args, **kwargs):
def __init__(self, instance=None, *args, **kwargs): # noqa
super(AliasForm, self).__init__(instance=instance, *args, **kwargs)
if instance:
self.fields['project'].queryset = (Project.objects
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/management/commands/clean_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def handle(self, *args, **options):
version = Version.objects.get(id=build['version'])
latest_build = version.builds.latest('date')
if latest_build.date > max_date:
log.warn('{0} is newer than {1}'.format(
log.warning('{0} is newer than {1}'.format(
latest_build, max_date))
path = version.get_build_path()
if path is not None:
Expand Down
5 changes: 2 additions & 3 deletions readthedocs/core/views/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def map_subproject_slug(view_func):
.. warning:: Does not take into account any kind of privacy settings.
"""
@wraps(view_func)
def inner_view(
request, subproject=None, subproject_slug=None, *args, **kwargs):
def inner_view(request, subproject=None, subproject_slug=None, *args, **kwargs): # noqa
if subproject is None and subproject_slug:
try:
subproject = Project.objects.get(slug=subproject_slug)
Expand Down Expand Up @@ -86,7 +85,7 @@ def map_project_slug(view_func):
.. warning:: Does not take into account any kind of privacy settings.
"""
@wraps(view_func)
def inner_view(request, project=None, project_slug=None, *args, **kwargs):
def inner_view(request, project=None, project_slug=None, *args, **kwargs): # noqa
if project is None:
if not project_slug:
project_slug = request.slug
Expand Down
20 changes: 10 additions & 10 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ def run_command_class(self, cls, cmd, **kwargs):
msg += u':\n{out}'.format(out=build_cmd.output)

if warn_only:
log.warn(LOG_TEMPLATE
.format(project=self.project.slug,
version=self.version.slug,
msg=msg))
log.warning(LOG_TEMPLATE
.format(project=self.project.slug,
version=self.version.slug,
msg=msg))
else:
raise BuildEnvironmentWarning(msg)
return build_cmd
Expand Down Expand Up @@ -561,12 +561,12 @@ def __enter__(self):
self.build['state'] = BUILD_STATE_FINISHED
raise exc
else:
log.warn(LOG_TEMPLATE
.format(
project=self.project.slug,
version=self.version.slug,
msg=("Removing stale container {0}"
.format(self.container_id))))
log.warning(LOG_TEMPLATE
.format(
project=self.project.slug,
version=self.version.slug,
msg=("Removing stale container {0}"
.format(self.container_id))))
client = self.get_client()
client.remove_container(self.container_id)
except (DockerAPIError, ConnectionError):
Expand Down
3 changes: 2 additions & 1 deletion readthedocs/doc_builder/python_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging
import os
import shutil
import six
from builtins import object, open

from django.conf import settings
Expand Down Expand Up @@ -163,7 +164,7 @@ def save_environment_json(self):
with open(self.environment_json_path(), 'w') as fpath:
# Compatibility for Py2 and Py3. ``io.TextIOWrapper`` expects
# unicode but ``json.dumps`` returns str in Py2.
fpath.write(unicode(json.dumps(data)))
fpath.write(six.text_type(json.dumps(data)))


class Virtualenv(PythonEnvironment):
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/notifications/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _get(self, *args, **kwargs):
safe_messages.append(message)
return safe_messages, all_ret

def add(self, level, message, extra_tags='', *args, **kwargs):
def add(self, level, message, extra_tags='', *args, **kwargs): # noqa
user = kwargs.get('user') or self.request.user
if not user.is_anonymous():
persist_messages = (PersistentMessage.objects
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/oauth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def get_serialized(self, key=None, default=None):
@property
def clone_fuzzy_url(self):
"""Try to match against several permutations of project URL."""
return
pass

def matches(self, user):
"""Projects that exist with repository URL already."""
Expand Down
1 change: 0 additions & 1 deletion readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,6 @@ def add_subproject(self, child, alias=None):

def remove_subproject(self, child):
ProjectRelationship.objects.filter(parent=self, child=child).delete()
return

def moderation_queue(self):
# non-optimal SQL warning.
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/rtd_tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@ def assertWizardFailure(self, response, field, match=None): # noqa
self.assertIn(field, response.context_data['wizard']['form'].errors)
if match is not None:
error = response.context_data['wizard']['form'].errors[field]
self.assertRegexpMatches(six.text_type(error), match)
self.assertRegexpMatches(six.text_type(error), match) # noqa
12 changes: 6 additions & 6 deletions readthedocs/search/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ def parse_sphinx_sections(content):
h1_title = h1_section.text().replace(u'¶', '').strip()
h1_id = div.attr('id')
h1_content = ""
next_p = next(body('h1'))
next_p = next(body('h1')) # pylint: disable=stop-iteration-return
while next_p:
if next_p[0].tag == 'div' and 'class' in next_p[0].attrib:
if 'section' in next_p[0].attrib['class']:
break
h1_content += "\n%s\n" % next_p.html()
next_p = next(next_p)
next_p = next(next_p) # pylint: disable=stop-iteration-return
if h1_content:
yield {
'id': h1_id,
Expand Down Expand Up @@ -228,14 +228,14 @@ def parse_mkdocs_sections(content):
h1_id = h1.attr('id')
h1_title = h1.text().strip()
h1_content = ""
next_p = next(body('h1'))
next_p = next(body('h1')) # pylint: disable=stop-iteration-return
while next_p:
if next_p[0].tag == 'h2':
break
h1_html = next_p.html()
if h1_html:
h1_content += "\n%s\n" % h1_html
next_p = next(next_p)
next_p = next(next_p) # pylint: disable=stop-iteration-return
if h1_content:
yield {
'id': h1_id,
Expand All @@ -250,14 +250,14 @@ def parse_mkdocs_sections(content):
h2_title = h2.text().strip()
section_id = h2.attr('id')
h2_content = ""
next_p = next(body('h2'))
next_p = next(body('h2')) # pylint: disable=stop-iteration-return
while next_p:
if next_p[0].tag == 'h2':
break
h2_html = next_p.html()
if h2_html:
h2_content += "\n%s\n" % h2_html
next_p = next(next_p)
next_p = next(next_p) # pylint: disable=stop-iteration-return
if h2_content:
yield {
'id': section_id,
Expand Down
6 changes: 4 additions & 2 deletions readthedocs/vcs_support/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ def __enter__(self):
self.name)
os.remove(self.fpath)
else:
raise LockTimeout("Lock (%s): Lock still active", self.name)
raise LockTimeout(
"Lock ({}): Lock still active".format(self.name))
elif path_exists:
raise LockTimeout("Lock (%s): Lock still active", self.name)
raise LockTimeout(
"Lock ({}): Lock still active".format(self.name))
open(self.fpath, 'w').close()
return self

Expand Down
8 changes: 1 addition & 7 deletions requirements/lint.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
-r pip.txt
maxcdn
astroid

# pylint 1.8.0 is having problems:
# File "/home/humitos/.pyenv/versions/2.7.14/envs/pylint/lib/python2.7/site-packages/pylint_django/plugin.py", line 22, in register
# start = name_checker.config.const_rgx.pattern[:-2]
# AttributeError: 'NoneType' object has no attribute 'pattern
pylint==1.7.5

pylint
prospector
pylint-django
pyflakes
4 changes: 2 additions & 2 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-r pip.txt

pytest<4,>=3.3.0
pytest<4,>=3.3.2
pytest-django==3.1.2
pytest-xdist==1.20.1
pytest-xdist==1.22.0
apipkg==1.4
execnet==1.5.0
Mercurial==4.4.2
Expand Down

0 comments on commit 7be1b80

Please sign in to comment.