diff options
author | Seth Morton <seth.m.morton@gmail.com> | 2020-11-22 21:42:42 -0800 |
---|---|---|
committer | Seth Morton <seth.m.morton@gmail.com> | 2020-11-22 21:52:45 -0800 |
commit | 05d54f4eb9f72b5139c282717c967c9631edfd7a (patch) | |
tree | a467d0c327ac239c1bcaaafdfbf7f8a2f3c3188b | |
parent | d6041271950cf022599e4fdccc82ee13e507704a (diff) | |
download | natsort-05d54f4eb9f72b5139c282717c967c9631edfd7a.tar.gz |
Run black
It turns out I had an error in the Travis-CI black invocation that cause
it to not actually catch formatting errors. Oops!
-rwxr-xr-x | dev/bump.py | 8 | ||||
-rw-r--r-- | docs/conf.py | 64 | ||||
-rw-r--r-- | natsort/compat/fake_fastnumbers.py | 5 | ||||
-rw-r--r-- | natsort/natsort.py | 4 | ||||
-rw-r--r-- | natsort/ns_enum.py | 4 | ||||
-rw-r--r-- | setup.py | 12 | ||||
-rw-r--r-- | tests/conftest.py | 3 | ||||
-rw-r--r-- | tests/test_final_data_transform_factory.py | 4 | ||||
-rw-r--r-- | tests/test_main.py | 4 | ||||
-rw-r--r-- | tests/test_natsorted.py | 6 | ||||
-rw-r--r-- | tests/test_natsorted_convenience.py | 4 | ||||
-rw-r--r-- | tests/test_regex.py | 2 | ||||
-rw-r--r-- | tests/test_string_component_transform_factory.py | 4 |
13 files changed, 56 insertions, 68 deletions
diff --git a/dev/bump.py b/dev/bump.py index 7ad0585..9bb2138 100755 --- a/dev/bump.py +++ b/dev/bump.py @@ -33,7 +33,9 @@ def bumpversion(severity, *args, catch=False): cmd = ["bump2version", *args, severity] try: if catch: - return subprocess.run(cmd, check=True, capture_output=True, text=True).stdout + return subprocess.run( + cmd, check=True, capture_output=True, text=True + ).stdout else: subprocess.run(cmd, check=True, text=True) except subprocess.CalledProcessError as e: @@ -57,8 +59,8 @@ with open("CHANGELOG.md") as fl: "<!---Comparison links-->\n[{new}]: {url}/{current}...{new}".format( new=data["new_version"], current=data["current_version"], - url="https://github.com/SethMMorton/natsort/compare" - ) + url="https://github.com/SethMMorton/natsort/compare", + ), ) with open("CHANGELOG.md", "w") as fl: fl.write(changelog) diff --git a/docs/conf.py b/docs/conf.py index 79de41a..4e87392 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,39 +28,39 @@ import os # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx.ext.intersphinx', - 'sphinx.ext.mathjax', - 'sphinx.ext.napoleon', - 'm2r2', + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.mathjax", + "sphinx.ext.napoleon", + "m2r2", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = ['.rst', '.md'] +source_suffix = [".rst", ".md"] # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'natsort' +project = "natsort" # noinspection PyShadowingBuiltins -copyright = '2014, Seth M. Morton' +copyright = "2014, Seth M. Morton" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The full version, including alpha/beta/rc tags. -release = '7.1.0' +release = "7.1.0" # The short X.Y version. -version = '.'.join(release.split('.')[0:2]) +version = ".".join(release.split(".")[0:2]) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -92,8 +92,8 @@ version = '.'.join(release.split('.')[0:2]) # show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' -highlight_language = 'python' +pygments_style = "sphinx" +highlight_language = "python" # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] @@ -106,13 +106,13 @@ highlight_language = 'python' # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -on_rtd = os.environ.get('READTHEDOCS') == 'True' +on_rtd = os.environ.get("READTHEDOCS") == "True" if on_rtd: - html_theme = 'default' + html_theme = "default" else: import sphinx_rtd_theme # noqa: F401 - html_theme = 'sphinx_rtd_theme' + html_theme = "sphinx_rtd_theme" # html_theme = 'solar' # Theme options are theme-specific and customize the look and feel of a theme @@ -121,7 +121,7 @@ else: # html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -html_theme_path = ['.'] +html_theme_path = ["."] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". @@ -191,17 +191,15 @@ html_theme_path = ['.'] # html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'natsortdoc' +htmlhelp_basename = "natsortdoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. # 'preamble': '', } @@ -210,8 +208,7 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'natsort.tex', 'natsort Documentation', - 'Seth M. Morton', 'manual'), + ("index", "natsort.tex", "natsort Documentation", "Seth M. Morton", "manual"), ] # The name of an image file (relative to this directory) to place at the top of @@ -239,10 +236,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'natsort', 'natsort Documentation', - ['Seth M. Morton'], 1) -] +man_pages = [("index", "natsort", "natsort Documentation", ["Seth M. Morton"], 1)] # If true, show URL addresses after external links. # man_show_urls = False @@ -254,9 +248,15 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'natsort', 'natsort Documentation', - 'Seth M. Morton', 'natsort', 'One line description of project.', - 'Miscellaneous'), + ( + "index", + "natsort", + "natsort Documentation", + "Seth M. Morton", + "natsort", + "One line description of project.", + "Miscellaneous", + ), ] # Documents to append as an appendix to all manuals. @@ -273,4 +273,4 @@ texinfo_documents = [ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'python': ('https://docs.python.org/3', None)} +intersphinx_mapping = {"python": ("https://docs.python.org/3", None)} diff --git a/natsort/compat/fake_fastnumbers.py b/natsort/compat/fake_fastnumbers.py index 9c0258f..7177551 100644 --- a/natsort/compat/fake_fastnumbers.py +++ b/natsort/compat/fake_fastnumbers.py @@ -81,10 +81,7 @@ def fast_float( # noinspection PyIncorrectDocstring def fast_int( - x, - key=lambda x: x, - _uni=unicodedata.digit, - _first_char=POTENTIAL_FIRST_CHAR, + x, key=lambda x: x, _uni=unicodedata.digit, _first_char=POTENTIAL_FIRST_CHAR ): """ Convert a string to a int quickly, return input as-is if not possible. diff --git a/natsort/natsort.py b/natsort/natsort.py index c4910e3..8e3a7b5 100644 --- a/natsort/natsort.py +++ b/natsort/natsort.py @@ -646,9 +646,7 @@ else: except ImportError: # No ICU installed def os_sort_keygen(key=None): - return natsort_keygen( - key=key, alg=ns.LOCALE | ns.PATH | ns.IGNORECASE - ) + return natsort_keygen(key=key, alg=ns.LOCALE | ns.PATH | ns.IGNORECASE) else: # ICU installed diff --git a/natsort/ns_enum.py b/natsort/ns_enum.py index fed7c38..283a793 100644 --- a/natsort/ns_enum.py +++ b/natsort/ns_enum.py @@ -65,9 +65,7 @@ for name, combo in enum_combos: combined_value |= enum_fields[combo_name] enum_fields[name] = combined_value -enum_fields.update( - (alias, enum_fields[name]) for alias, name in enum_aliases -) +enum_fields.update((alias, enum_fields[name]) for alias, name in enum_aliases) # Subclass the namedtuple to improve the docstring. @@ -1,14 +1,12 @@ #! /usr/bin/env python from setuptools import find_packages, setup + setup( - name='natsort', - version='7.1.0', + name="natsort", + version="7.1.0", packages=find_packages(), - entry_points={'console_scripts': ['natsort = natsort.__main__:main']}, + entry_points={"console_scripts": ["natsort = natsort.__main__:main"]}, python_requires=">=3.4", - extras_require={ - 'fast': ["fastnumbers >= 2.0.0"], - 'icu': ["PyICU >= 1.0.0"] - } + extras_require={"fast": ["fastnumbers >= 2.0.0"], "icu": ["PyICU >= 1.0.0"]}, ) diff --git a/tests/conftest.py b/tests/conftest.py index d584789..74d7f4f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,8 +12,7 @@ import pytest # For some reason it thinks that the text/binary generation is too # slow then causes the tests to fail. hypothesis.settings.register_profile( - "slow-tests", - suppress_health_check=[hypothesis.HealthCheck.too_slow], + "slow-tests", suppress_health_check=[hypothesis.HealthCheck.too_slow] ) diff --git a/tests/test_final_data_transform_factory.py b/tests/test_final_data_transform_factory.py index dc6e1db..f6bf636 100644 --- a/tests/test_final_data_transform_factory.py +++ b/tests/test_final_data_transform_factory.py @@ -26,8 +26,8 @@ def test_final_data_transform_factory_default(x, y, alg): (ns.LOCALE | ns.UNGROUPLETTERS | NS_DUMB, lambda x: x), (ns.LOCALE | ns.UNGROUPLETTERS | ns.LOWERCASEFIRST, lambda x: x), ( - ns.LOCALE | ns.UNGROUPLETTERS | NS_DUMB | ns.LOWERCASEFIRST, - lambda x: x.swapcase(), + ns.LOCALE | ns.UNGROUPLETTERS | NS_DUMB | ns.LOWERCASEFIRST, + lambda x: x.swapcase(), ), ], ) diff --git a/tests/test_main.py b/tests/test_main.py index 1b01fbf..da91fdd 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -151,11 +151,11 @@ def test_range_check_returns_range_as_is_but_with_floats_example(): assert range_check(6.4, 30) == (6.4, 30.0) -@given(x=floats(allow_nan=False, min_value=-1E8, max_value=1E8) | integers(), d=data()) +@given(x=floats(allow_nan=False, min_value=-1e8, max_value=1e8) | integers(), d=data()) def test_range_check_returns_range_as_is_if_first_is_less_than_second(x, d): # Pull data such that the first is less than the second. if isinstance(x, float): - y = d.draw(floats(min_value=x + 1.0, max_value=1E9, allow_nan=False)) + y = d.draw(floats(min_value=x + 1.0, max_value=1e9, allow_nan=False)) else: y = d.draw(integers(min_value=x + 1)) assert range_check(x, y) == (x, y) diff --git a/tests/test_natsorted.py b/tests/test_natsorted.py index 2a881f1..4254e6c 100644 --- a/tests/test_natsorted.py +++ b/tests/test_natsorted.py @@ -88,12 +88,12 @@ def test_natsorted_handles_mixed_types(mixed_list, alg, expected): @pytest.mark.parametrize( "alg, expected, slc", [ - (ns.DEFAULT, [float("nan"), 5, "25", 1E40], slice(1, None)), - (ns.NANLAST, [5, "25", 1E40, float("nan")], slice(None, 3)), + (ns.DEFAULT, [float("nan"), 5, "25", 1e40], slice(1, None)), + (ns.NANLAST, [5, "25", 1e40, float("nan")], slice(None, 3)), ], ) def test_natsorted_handles_nan(alg, expected, slc): - given = ["25", 5, float("nan"), 1E40] + given = ["25", 5, float("nan"), 1e40] # The slice is because NaN != NaN # noinspection PyUnresolvedReferences assert natsorted(given, alg=alg)[slc] == expected[slc] diff --git a/tests/test_natsorted_convenience.py b/tests/test_natsorted_convenience.py index 7a91556..cdc2c50 100644 --- a/tests/test_natsorted_convenience.py +++ b/tests/test_natsorted_convenience.py @@ -43,9 +43,7 @@ def test_decoder_returns_function_that_can_decode_bytes_but_return_non_bytes_as_ int_obj = 14 assert func(b"bytes") == str_obj assert func(int_obj) is int_obj # returns as-is, same object ID - assert ( - func(str_obj) is str_obj - ) # same object returned b/c only bytes has decode + assert func(str_obj) is str_obj # same object returned b/c only bytes has decode def test_as_ascii_converts_bytes_to_ascii(): diff --git a/tests/test_regex.py b/tests/test_regex.py index 8d12969..f647f5f 100644 --- a/tests/test_regex.py +++ b/tests/test_regex.py @@ -81,7 +81,7 @@ regex_tests = { f_s: ["", "12", "", "①", "", "②", "", "Ⅰ", "", "Ⅱ", "", "⅓", ""], f_ue: ["", "12", "", "①", "", "②", "", "Ⅰ", "", "Ⅱ", "", "⅓", ""], f_se: ["", "12", "", "①", "", "②", "", "Ⅰ", "", "Ⅱ", "", "⅓", ""], - } + }, } diff --git a/tests/test_string_component_transform_factory.py b/tests/test_string_component_transform_factory.py index c48138f..8b77d38 100644 --- a/tests/test_string_component_transform_factory.py +++ b/tests/test_string_component_transform_factory.py @@ -15,9 +15,7 @@ from natsort.utils import groupletters, string_component_transform_factory # library on BSD systems that has nothing to do with natsort (a ValueError is # raised by strxfrm). Let's filter them out. try: - bad_uni_chars = frozenset( - chr(x) for x in range(0X10fefd, 0X10ffff + 1) - ) + bad_uni_chars = frozenset(chr(x) for x in range(0x10FEFD, 0x10FFFF + 1)) except ValueError: # Narrow unicode build... no worries. bad_uni_chars = frozenset() |