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 Oct 18, 2022
1 parent 872830c commit 6c4abce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class NewlineHelpFormatter(argparse.HelpFormatter):

def _split_lines(self, text, width):
parts = text.split('\n')
out = list()
out = []
for part in parts:
# Eventually we could allow others...
indent_start = '- '
Expand Down Expand Up @@ -406,7 +406,7 @@ def parse_options(args):
config = configparser.ConfigParser()

# Read toml before other config files.
toml_files_errors = list()
toml_files_errors = []
if os.path.isfile('pyproject.toml'):
toml_files_errors.append(('pyproject.toml', False))
if options.toml:
Expand Down Expand Up @@ -820,7 +820,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 @@ -844,7 +844,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 6c4abce

Please sign in to comment.