Skip to content

Commit

Permalink
Replace list()/dict() with literals
Browse files Browse the repository at this point in the history
Literals are always faster and conventional in modern Python style.
  • Loading branch information
jdufresne committed Jun 26, 2022
1 parent 718b8d1 commit 7195b9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class NewlineHelpFormatter(argparse.HelpFormatter):

def _split_lines(self, text, width):
parts = text.split('\n')
out = list()
out = []
for pi, part in enumerate(parts):
# Eventually we could allow others...
indent_start = '- '
Expand Down Expand Up @@ -800,7 +800,7 @@ def main(*args):
dictionaries = options.dictionary
else:
dictionaries = ['-']
use_dictionaries = list()
use_dictionaries = []
for dictionary in dictionaries:
if dictionary == "-":
# figure out which builtin dictionaries to use
Expand All @@ -824,7 +824,7 @@ def main(*args):
parser.print_help()
return EX_USAGE
use_dictionaries.append(dictionary)
misspellings = dict()
misspellings = {}
for dictionary in use_dictionaries:
build_dict(dictionary, misspellings, ignore_words)
colors = TermColors()
Expand Down
8 changes: 4 additions & 4 deletions codespell_lib/tests/test_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from codespell_lib._codespell import _builtin_dictionaries
from codespell_lib._codespell import supported_languages

spellers = dict()
spellers = {}

try:
import aspell
Expand All @@ -28,7 +28,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 @@ -50,7 +50,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 Down Expand Up @@ -210,7 +210,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

0 comments on commit 7195b9a

Please sign in to comment.