Skip to content

Fix lint issues for privacy app #2888

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

Merged
merged 6 commits into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion prospector-more.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ ignore-paths:
- donate/
- notifications/
- payments/
- privacy/
- profiles/
- projects/
- redirects/
Expand Down
3 changes: 2 additions & 1 deletion readthedocs/privacy/backend.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Django Managers and Querysets to apply project privacy restrictions."""
from django.db import models

from guardian.shortcuts import get_objects_for_user
Expand Down Expand Up @@ -85,7 +86,7 @@ def from_queryset(cls, queryset_class, class_name=None):
# no direct members.
queryset_class = get_override_class(
VersionQuerySet,
VersionQuerySet._default_class
VersionQuerySet._default_class # pylint: disable=protected-access
)
return super(VersionManager, cls).from_queryset(queryset_class, class_name)

Expand Down
27 changes: 19 additions & 8 deletions readthedocs/privacy/backends/syncers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""Classes allowing copying files around.

"Syncers" copy files from the local machine, while "Pullers" copy files to
the local machine.

"""
import getpass
import logging
import os
Expand All @@ -8,12 +14,17 @@
log = logging.getLogger(__name__)


# The file builting was removed in Python 3, so we should not use it
# Setting to None here to silence pylint for this builtin only
file = None # pylint: disable=redefined-builtin
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps instead this should just rename the file argument on the various copy methods to not use a builtin. A quick search shows this as the only mention of the file argument:

https://github.com/rtfd/readthedocs.org/blob/b9f15d9172df2d2d0c2f5fc132ba9c1b25faf709/readthedocs/projects/tasks.py#L857

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my first thought, but I wasn't sure if my searches were finding everything. I'll go ahead and do this.



class LocalSyncer(object):

@classmethod
def copy(cls, path, target, file=False, **kwargs):
def copy(cls, path, target, file=False, **__):
"""A copy command that works with files or directories."""
log.info("Local Copy %s to %s" % (path, target))
log.info("Local Copy %s to %s", path, target)
if file:
if path == target:
# Don't copy the same file over itself
Expand All @@ -30,7 +41,7 @@ def copy(cls, path, target, file=False, **kwargs):
class RemoteSyncer(object):

@classmethod
def copy(cls, path, target, file=False, **kwargs):
def copy(cls, path, target, file=False, **__):
"""
A better copy command that works with files or directories.

Expand All @@ -39,7 +50,7 @@ def copy(cls, path, target, file=False, **kwargs):
sync_user = getattr(settings, 'SYNC_USER', getpass.getuser())
app_servers = getattr(settings, 'MULTIPLE_APP_SERVERS', [])
if app_servers:
log.info("Remote Copy %s to %s" % (path, target))
log.info("Remote Copy %s to %s on %s", path, target, app_servers)
for server in app_servers:
mkdir_cmd = ("ssh %s@%s mkdir -p %s" % (sync_user, server, target))
ret = os.system(mkdir_cmd)
Expand Down Expand Up @@ -68,7 +79,7 @@ def copy(cls, path, target, file=False, **kwargs):
class DoubleRemotePuller(object):

@classmethod
def copy(cls, path, target, host, file=False, **kwargs):
def copy(cls, path, target, host, file=False, **__):
"""
A better copy command that works from the webs.

Expand All @@ -78,7 +89,7 @@ def copy(cls, path, target, host, file=False, **kwargs):
app_servers = getattr(settings, 'MULTIPLE_APP_SERVERS', [])
if not file:
path += "/"
log.info("Remote Copy %s to %s" % (path, target))
log.info("Remote Copy %s to %s", path, target)
for server in app_servers:
if not file:
mkdir_cmd = "ssh {user}@{server} mkdir -p {target}".format(
Expand Down Expand Up @@ -106,7 +117,7 @@ def copy(cls, path, target, host, file=False, **kwargs):
class RemotePuller(object):

@classmethod
def copy(cls, path, target, host, file=False, **kwargs):
def copy(cls, path, target, host, file=False, **__):
"""
A better copy command that works from the webs.

Expand All @@ -115,7 +126,7 @@ def copy(cls, path, target, host, file=False, **kwargs):
sync_user = getattr(settings, 'SYNC_USER', getpass.getuser())
if not file:
path += "/"
log.info("Local Copy %s to %s" % (path, target))
log.info("Local Copy %s to %s", path, target)
os.makedirs(target)
# Add a slash when copying directories
sync_cmd = "rsync -e 'ssh -T' -av --delete {user}@{host}:{path} {target}".format(
Expand Down
7 changes: 7 additions & 0 deletions readthedocs/privacy/loader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""A namespace of privacy classes configured by settings.

Importing classes from this module allows the classes used to be overridden
using Django settings.

"""

from readthedocs.core.utils.extend import SettingsOverrideObject
from readthedocs.privacy import backend

Expand Down
2 changes: 2 additions & 0 deletions readthedocs/privacy/templatetags/privacy_tags.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Template tags to query projects by privacy."""

from django import template

from ..loader import AdminPermission
Expand Down