Skip to content

Commit

Permalink
Fix some code quality issues
Browse files Browse the repository at this point in the history
  • Loading branch information
deepsourcebot authored and pnijhara committed Apr 11, 2020
1 parent d7c57ab commit 1c02b6f
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 18 deletions.
12 changes: 12 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version = 1

test_patterns = ["tests/**"]

exclude_patterns = ["tests/data"]

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
4 changes: 2 additions & 2 deletions gitsome/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def completing_subcommand_option(self, words, word_before_cursor):
:return: A list of options.
"""
options = []
for subcommand, args_opts in COMPLETIONS_GH.items():
for subcommand, _ in COMPLETIONS_GH.items():
if subcommand in words and \
(words[-2] == subcommand or
self.completing_subcommand_option_util(subcommand, words)):
Expand Down Expand Up @@ -183,7 +183,7 @@ def arg_completions(self, words, word_before_cursor):
"""
if 'gh' not in words:
return []
for subcommand, args_opts in COMPLETIONS_GH.items():
for subcommand, _ in COMPLETIONS_GH.items():
if subcommand in words:
args = list(COMPLETIONS_GH[subcommand]['args'].keys())
if not args:
Expand Down
2 changes: 1 addition & 1 deletion gitsome/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def pull_requests(self, limit=1000, pager=False):
repo_pulls = repository.pull_requests()
for repo_pull in repo_pulls:
url = self.formatter.format_issues_url_from_issue(repo_pull)
user, repo, issues, number = url.split('/')
user, repo, _, number = url.split('/')
repo_pull = self.config.api.pull_request(user, repo, number)
issues_list.append(repo_pull)
self.issues(issues_list, limit, pager)
Expand Down
4 changes: 3 additions & 1 deletion gitsome/lib/github3/gists/gist.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def delete(self):
return self._boolean(self._delete(self._api), 204, 404)

@requires_auth
def edit(self, description='', files={}):
def edit(self, description='', files=None):
"""Edit this gist.
:param str description: (optional), description of the gist
Expand All @@ -138,6 +138,8 @@ def edit(self, description='', files={}):
:returns: bool -- whether the edit was successful
"""
if files is None:
files = {}
data = {}
json = None
if description:
Expand Down
12 changes: 9 additions & 3 deletions gitsome/lib/github3/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ def _repr(self):
return '<GitHub at 0x{0:x}>'.format(id(self))

@requires_auth
def add_email_addresses(self, addresses=[]):
def add_email_addresses(self, addresses=None):
"""Add the email addresses in ``addresses`` to the authenticated
user's account.
:param list addresses: (optional), email addresses to be added
:returns: list of :class:`~github3.users.Email`
"""
if addresses is None:
addresses = []
json = []
if addresses:
url = self._build_url('user', 'emails')
Expand Down Expand Up @@ -252,7 +254,7 @@ def create_gist(self, description, files, public=True):

@requires_auth
def create_issue(self, owner, repository, title, body=None, assignee=None,
milestone=None, labels=[]):
milestone=None, labels=None):
"""Create an issue on the project 'repository' owned by 'owner'
with title 'title'.
Expand Down Expand Up @@ -280,6 +282,8 @@ def create_issue(self, owner, repository, title, body=None, assignee=None,
:param list labels: (optional), List of label names.
:returns: :class:`Issue <github3.issues.Issue>` if successful
"""
if labels is None:
labels = []
repo = None
if owner and repository and title:
repo = self.repository(owner, repository)
Expand Down Expand Up @@ -349,13 +353,15 @@ def create_repository(self, name, description='', homepage='',
return self._instance_or_null(Repository, json)

@requires_auth
def delete_email_addresses(self, addresses=[]):
def delete_email_addresses(self, addresses=None):
"""Delete the email addresses in ``addresses`` from the
authenticated user's account.
:param list addresses: (optional), email addresses to be removed
:returns: bool
"""
if addresses is None:
addresses = []
url = self._build_url('user', 'emails')
return self._boolean(self._delete(url, data=json.dumps(addresses)),
204, 404)
Expand Down
4 changes: 2 additions & 2 deletions xonsh/jupyter_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def parser(self):

def make_default_config(self):
"""Provides default configuration"""
ns, unknown = self.parser.parse_known_args(sys.argv)
ns, _ = self.parser.parse_known_args(sys.argv)
if ns.config_file is None:
self.dprint(1, "Starting xonsh kernel with default args...")
config = {
Expand Down Expand Up @@ -125,7 +125,7 @@ def iopub_handler(self, message):
def control_handler(self, wire_message):
"""Handles control requests"""
self.dprint(1, "control received:", wire_message)
identities, msg = self.deserialize_wire_message(wire_message)
_, msg = self.deserialize_wire_message(wire_message)
if msg["header"]["msg_type"] == "shutdown_request":
self.shutdown()

Expand Down
2 changes: 1 addition & 1 deletion xonsh/lazyjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _to_json_with_size(obj, offset=0, sort_keys=False):
size = {}
items = sorted(obj.items()) if sort_keys else obj.items()
for key, val in items:
s_k, o_k, n_k, size_k = _to_json_with_size(
s_k, _, n_k, _ = _to_json_with_size(
key, offset=j, sort_keys=sort_keys
)
s += s_k + ": "
Expand Down
2 changes: 1 addition & 1 deletion xonsh/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _end_delimiter(state, token):
s = token.string
l, c = token.start
if len(py) > 1:
mode, orig, match, pos = py.pop()
_, orig, match, pos = py.pop()
if s != match:
e = '"{}" at {} ends "{}" at {} (expected "{}")'
return e.format(s, (l, c), orig, pos, match)
Expand Down
8 changes: 4 additions & 4 deletions xonsh/parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ def p_comma_import_as_name(self, p):

def p_comma_import_as_name_tail(self, p):
"""comma_import_as_name : comma_opt RPAREN"""
p[0] = list()
p[0] = []

def p_dotted_as_name(self, p):
"""dotted_as_name : dotted_name as_name_opt"""
Expand Down Expand Up @@ -2215,7 +2215,7 @@ def apply_trailers(self, leader, trailers):
gblcall = xonsh_call("globals", [], lineno=l, col=c)
loccall = xonsh_call("locals", [], lineno=l, col=c)
if isinstance(trailer, tuple):
trailer, arglist = trailer
trailer, _ = trailer
margs = [leader, trailer, gblcall, loccall]
p0 = xonsh_call("__xonsh__.call_macro", margs, lineno=l, col=c)
elif isinstance(trailer, str):
Expand Down Expand Up @@ -2702,7 +2702,7 @@ def p_testlist_single(self, p):
if isinstance(p1, ast.List) or (
isinstance(p1, ast.Tuple) and hasattr(p1, "_real_tuple") and p1._real_tuple
):
lineno, col = lopen_loc(p1)
_, _ = lopen_loc(p1)
p[0] = ast.Tuple(
elts=[p1], ctx=ast.Load(), lineno=p1.lineno, col_offset=p1.col_offset
)
Expand All @@ -2717,7 +2717,7 @@ def p_testlist_many(self, p):
if isinstance(p1, ast.List) or (
isinstance(p1, ast.Tuple) and hasattr(p1, "_real_tuple") and p1._real_tuple
):
lineno, col = lopen_loc(p1)
_, _ = lopen_loc(p1)
p1 = ast.Tuple(
elts=[p1], ctx=ast.Load(), lineno=p1.lineno, col_offset=p1.col_offset
)
Expand Down
4 changes: 3 additions & 1 deletion xonsh/ply/ply/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,9 @@ def undef(self,tokens):
#
# Parse input text.
# ----------------------------------------------------------------------
def parse(self,input,source=None,ignore={}):
def parse(self,input,source=None,ignore=None):
if ignore is None:
ignore = {}
self.ignore = ignore
self.parser = self.parsegen(input,source)

Expand Down
4 changes: 2 additions & 2 deletions xonsh/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ def to_dict(x):
except (ValueError, SyntaxError):
msg = '"{}" can not be converted to Python dictionary.'.format(x)
warnings.warn(msg, RuntimeWarning)
x = dict()
x = {}
return x


Expand All @@ -1536,7 +1536,7 @@ def to_str_str_dict(x):
if not is_str_str_dict(x):
msg = '"{}" can not be converted to str:str dictionary.'.format(x)
warnings.warn(msg, RuntimeWarning)
x = dict()
x = {}
return x


Expand Down

0 comments on commit 1c02b6f

Please sign in to comment.