Skip to content
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

Fix Deepsource issues #2085

Merged
merged 5 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def ask_for_word_fix(line, wrongword, misspelling, interactivity):
r = sys.stdin.readline().strip().upper()
if not r:
r = 'Y'
if r != 'Y' and r != 'N':
if r not in ('Y', 'N'):
print("Say 'y' or 'n'")
r = ''

Expand All @@ -551,8 +551,8 @@ def ask_for_word_fix(line, wrongword, misspelling, interactivity):
opt = [w.strip() for w in misspelling.data.split(',')]
while not r:
print("%s Choose an option (blank for none): " % line, end='')
for i in range(len(opt)):
fixword = fix_case(wrongword, opt[i])
for i, o in enumerate(opt):
fixword = fix_case(wrongword, o)
print(" %d) %s" % (i, fixword), end='')
print(": ", end='')
sys.stdout.flush()
Expand Down
3 changes: 2 additions & 1 deletion codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def test_constants():
class MainWrapper:
"""Compatibility wrapper for when we used to return the count."""

def main(self, *args, count=True, std=False, **kwargs):
@staticmethod
def main(*args, count=True, std=False, **kwargs):
if count:
args = ('--count',) + args
code = cs_.main(*args, **kwargs)
Expand Down
10 changes: 5 additions & 5 deletions codespell_lib/tests/test_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from codespell_lib._codespell import _builtin_dictionaries
from codespell_lib._codespell import supported_languages

spellers = dict()
spellers = {}

try:
import aspell
Expand All @@ -26,7 +26,7 @@
'aspell not found, but not required, skipping aspell tests. Got '
'error during import:\n%s' % (exp,))

global_err_dicts = dict()
global_err_dicts = {}
global_pairs = set()

# Filename, should be seen as errors in aspell or not
Expand All @@ -48,7 +48,7 @@ def test_dictionaries_exist():
@fname_params
def test_dictionary_formatting(fname, in_aspell, in_dictionary):
"""Test that all dictionary entries are valid."""
errors = list()
errors = []
with open(fname, 'rb') as fid:
for line in fid:
err, rep = line.decode('utf-8').split('->')
Expand All @@ -58,7 +58,7 @@ def test_dictionary_formatting(fname, in_aspell, in_dictionary):
_check_err_rep(err, rep, in_aspell, fname, in_dictionary)
except AssertionError as exp:
errors.append(str(exp).split('\n')[0])
if len(errors):
if errors:
raise AssertionError('\n' + '\n'.join(errors))


Expand Down Expand Up @@ -208,7 +208,7 @@ def test_error_checking_in_aspell(err, rep, err_aspell, rep_aspell, match):
@pytest.mark.dependency(name='dictionary loop')
def test_dictionary_looping(fname, in_aspell, in_dictionary):
"""Test that all dictionary entries are valid."""
this_err_dict = dict()
this_err_dict = {}
short_fname = op.basename(fname)
with open(fname, 'rb') as fid:
for line in fid:
Expand Down