Skip to content

Commit 1c02b6f

Browse files
deepsourcebotpnijhara
authored andcommitted
Fix some code quality issues
1 parent d7c57ab commit 1c02b6f

11 files changed

Lines changed: 40 additions & 18 deletions

File tree

.deepsource.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version = 1
2+
3+
test_patterns = ["tests/**"]
4+
5+
exclude_patterns = ["tests/data"]
6+
7+
[[analyzers]]
8+
name = "python"
9+
enabled = true
10+
11+
[analyzers.meta]
12+
runtime_version = "3.x.x"

gitsome/completer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def completing_subcommand_option(self, words, word_before_cursor):
140140
:return: A list of options.
141141
"""
142142
options = []
143-
for subcommand, args_opts in COMPLETIONS_GH.items():
143+
for subcommand, _ in COMPLETIONS_GH.items():
144144
if subcommand in words and \
145145
(words[-2] == subcommand or
146146
self.completing_subcommand_option_util(subcommand, words)):
@@ -183,7 +183,7 @@ def arg_completions(self, words, word_before_cursor):
183183
"""
184184
if 'gh' not in words:
185185
return []
186-
for subcommand, args_opts in COMPLETIONS_GH.items():
186+
for subcommand, _ in COMPLETIONS_GH.items():
187187
if subcommand in words:
188188
args = list(COMPLETIONS_GH[subcommand]['args'].keys())
189189
if not args:

gitsome/github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def pull_requests(self, limit=1000, pager=False):
575575
repo_pulls = repository.pull_requests()
576576
for repo_pull in repo_pulls:
577577
url = self.formatter.format_issues_url_from_issue(repo_pull)
578-
user, repo, issues, number = url.split('/')
578+
user, repo, _, number = url.split('/')
579579
repo_pull = self.config.api.pull_request(user, repo, number)
580580
issues_list.append(repo_pull)
581581
self.issues(issues_list, limit, pager)

gitsome/lib/github3/gists/gist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def delete(self):
126126
return self._boolean(self._delete(self._api), 204, 404)
127127

128128
@requires_auth
129-
def edit(self, description='', files={}):
129+
def edit(self, description='', files=None):
130130
"""Edit this gist.
131131
132132
:param str description: (optional), description of the gist
@@ -138,6 +138,8 @@ def edit(self, description='', files={}):
138138
:returns: bool -- whether the edit was successful
139139
140140
"""
141+
if files is None:
142+
files = {}
141143
data = {}
142144
json = None
143145
if description:

gitsome/lib/github3/github.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ def _repr(self):
6868
return '<GitHub at 0x{0:x}>'.format(id(self))
6969

7070
@requires_auth
71-
def add_email_addresses(self, addresses=[]):
71+
def add_email_addresses(self, addresses=None):
7272
"""Add the email addresses in ``addresses`` to the authenticated
7373
user's account.
7474
7575
:param list addresses: (optional), email addresses to be added
7676
:returns: list of :class:`~github3.users.Email`
7777
"""
78+
if addresses is None:
79+
addresses = []
7880
json = []
7981
if addresses:
8082
url = self._build_url('user', 'emails')
@@ -252,7 +254,7 @@ def create_gist(self, description, files, public=True):
252254

253255
@requires_auth
254256
def create_issue(self, owner, repository, title, body=None, assignee=None,
255-
milestone=None, labels=[]):
257+
milestone=None, labels=None):
256258
"""Create an issue on the project 'repository' owned by 'owner'
257259
with title 'title'.
258260
@@ -280,6 +282,8 @@ def create_issue(self, owner, repository, title, body=None, assignee=None,
280282
:param list labels: (optional), List of label names.
281283
:returns: :class:`Issue <github3.issues.Issue>` if successful
282284
"""
285+
if labels is None:
286+
labels = []
283287
repo = None
284288
if owner and repository and title:
285289
repo = self.repository(owner, repository)
@@ -349,13 +353,15 @@ def create_repository(self, name, description='', homepage='',
349353
return self._instance_or_null(Repository, json)
350354

351355
@requires_auth
352-
def delete_email_addresses(self, addresses=[]):
356+
def delete_email_addresses(self, addresses=None):
353357
"""Delete the email addresses in ``addresses`` from the
354358
authenticated user's account.
355359
356360
:param list addresses: (optional), email addresses to be removed
357361
:returns: bool
358362
"""
363+
if addresses is None:
364+
addresses = []
359365
url = self._build_url('user', 'emails')
360366
return self._boolean(self._delete(url, data=json.dumps(addresses)),
361367
204, 404)

xonsh/jupyter_kernel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def parser(self):
9797

9898
def make_default_config(self):
9999
"""Provides default configuration"""
100-
ns, unknown = self.parser.parse_known_args(sys.argv)
100+
ns, _ = self.parser.parse_known_args(sys.argv)
101101
if ns.config_file is None:
102102
self.dprint(1, "Starting xonsh kernel with default args...")
103103
config = {
@@ -125,7 +125,7 @@ def iopub_handler(self, message):
125125
def control_handler(self, wire_message):
126126
"""Handles control requests"""
127127
self.dprint(1, "control received:", wire_message)
128-
identities, msg = self.deserialize_wire_message(wire_message)
128+
_, msg = self.deserialize_wire_message(wire_message)
129129
if msg["header"]["msg_type"] == "shutdown_request":
130130
self.shutdown()
131131

xonsh/lazyjson.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def _to_json_with_size(obj, offset=0, sort_keys=False):
1919
size = {}
2020
items = sorted(obj.items()) if sort_keys else obj.items()
2121
for key, val in items:
22-
s_k, o_k, n_k, size_k = _to_json_with_size(
22+
s_k, _, n_k, _ = _to_json_with_size(
2323
key, offset=j, sort_keys=sort_keys
2424
)
2525
s += s_k + ": "

xonsh/lexer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _end_delimiter(state, token):
151151
s = token.string
152152
l, c = token.start
153153
if len(py) > 1:
154-
mode, orig, match, pos = py.pop()
154+
_, orig, match, pos = py.pop()
155155
if s != match:
156156
e = '"{}" at {} ends "{}" at {} (expected "{}")'
157157
return e.format(s, (l, c), orig, pos, match)

xonsh/parsers/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ def p_comma_import_as_name(self, p):
14581458

14591459
def p_comma_import_as_name_tail(self, p):
14601460
"""comma_import_as_name : comma_opt RPAREN"""
1461-
p[0] = list()
1461+
p[0] = []
14621462

14631463
def p_dotted_as_name(self, p):
14641464
"""dotted_as_name : dotted_name as_name_opt"""
@@ -2215,7 +2215,7 @@ def apply_trailers(self, leader, trailers):
22152215
gblcall = xonsh_call("globals", [], lineno=l, col=c)
22162216
loccall = xonsh_call("locals", [], lineno=l, col=c)
22172217
if isinstance(trailer, tuple):
2218-
trailer, arglist = trailer
2218+
trailer, _ = trailer
22192219
margs = [leader, trailer, gblcall, loccall]
22202220
p0 = xonsh_call("__xonsh__.call_macro", margs, lineno=l, col=c)
22212221
elif isinstance(trailer, str):
@@ -2702,7 +2702,7 @@ def p_testlist_single(self, p):
27022702
if isinstance(p1, ast.List) or (
27032703
isinstance(p1, ast.Tuple) and hasattr(p1, "_real_tuple") and p1._real_tuple
27042704
):
2705-
lineno, col = lopen_loc(p1)
2705+
_, _ = lopen_loc(p1)
27062706
p[0] = ast.Tuple(
27072707
elts=[p1], ctx=ast.Load(), lineno=p1.lineno, col_offset=p1.col_offset
27082708
)
@@ -2717,7 +2717,7 @@ def p_testlist_many(self, p):
27172717
if isinstance(p1, ast.List) or (
27182718
isinstance(p1, ast.Tuple) and hasattr(p1, "_real_tuple") and p1._real_tuple
27192719
):
2720-
lineno, col = lopen_loc(p1)
2720+
_, _ = lopen_loc(p1)
27212721
p1 = ast.Tuple(
27222722
elts=[p1], ctx=ast.Load(), lineno=p1.lineno, col_offset=p1.col_offset
27232723
)

xonsh/ply/ply/cpp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,9 @@ def undef(self,tokens):
939939
#
940940
# Parse input text.
941941
# ----------------------------------------------------------------------
942-
def parse(self,input,source=None,ignore={}):
942+
def parse(self,input,source=None,ignore=None):
943+
if ignore is None:
944+
ignore = {}
943945
self.ignore = ignore
944946
self.parser = self.parsegen(input,source)
945947

0 commit comments

Comments
 (0)