diff --git a/Makefile b/Makefile index 454702c6..a04a9c86 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ format: ## Format files to match style lint: ## Check style with various tools poetry check - poetry run pyflakes jrnl tests + poetry run pflake8 jrnl tests poetry run black --check --diff . unit: # unit tests diff --git a/jrnl/DayOneJournal.py b/jrnl/DayOneJournal.py index 00271875..01b934e5 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -78,35 +78,35 @@ class DayOne(Journal.Journal): entry.creator_device_agent = dict_entry["Creator"][ "Device Agent" ] - except: + except: # noqa: E722 pass try: entry.creator_generation_date = dict_entry["Creator"][ "Generation Date" ] - except: + except: # noqa: E722 entry.creator_generation_date = date try: entry.creator_host_name = dict_entry["Creator"]["Host Name"] - except: + except: # noqa: E722 pass try: entry.creator_os_agent = dict_entry["Creator"]["OS Agent"] - except: + except: # noqa: E722 pass try: entry.creator_software_agent = dict_entry["Creator"][ "Software Agent" ] - except: + except: # noqa: E722 pass try: entry.location = dict_entry["Location"] - except: + except: # noqa: E722 pass try: entry.weather = dict_entry["Weather"] - except: + except: # noqa: E722 pass self.entries.append(entry) self.sort() diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 181d85c4..6d3c6886 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -220,7 +220,10 @@ class Journal: # If strict mode is on, all tags have to be present in entry tagged = self.search_tags.issubset if strict else self.search_tags.intersection - excluded = lambda tags: len([tag for tag in tags if tag in excluded_tags]) > 0 + + def excluded(tags): + return 0 < len([tag for tag in tags if tag in excluded_tags]) + if contains: contains_lower = contains.casefold() diff --git a/jrnl/exception.py b/jrnl/exception.py index cb6672d7..07bf9023 100644 --- a/jrnl/exception.py +++ b/jrnl/exception.py @@ -22,25 +22,24 @@ class JrnlError(Exception): def _get_error_message(self, **kwargs): error_messages = { - "ConfigDirectoryIsFile": textwrap.dedent( - """ + "ConfigDirectoryIsFile": """ The path to your jrnl configuration directory is a file, not a directory: {config_directory_path} Removing this file will allow jrnl to save its configuration. - """ - ), - "LineWrapTooSmallForDateFormat": textwrap.dedent( - """ - The provided linewrap value of {config_linewrap} is too small by {columns} columns - to display the timestamps in the configured time format for journal {journal}. + """, + "LineWrapTooSmallForDateFormat": """ + The provided linewrap value of {config_linewrap} is too small by + {columns} columns to display the timestamps in the configured time + format for journal {journal}. - You can avoid this error by specifying a linewrap value that is larger by at least {columns} in the configuration file or by using --config-override at the command line - """ - ), + You can avoid this error by specifying a linewrap value that is larger + by at least {columns} in the configuration file or by using + --config-override at the command line + """, } - return error_messages[self.error_type].format(**kwargs) - - pass + msg = error_messages[self.error_type].format(**kwargs) + msg = textwrap.dedent(msg) + return msg diff --git a/poetry.lock b/poetry.lock index 65670545..50b41e3c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -41,7 +41,7 @@ test = ["coverage", "flake8", "pexpect", "wheel"] [[package]] name = "asteval" -version = "0.9.23" +version = "0.9.25" description = "Safe, minimalistic evaluator of python expression using ast module" category = "main" optional = false @@ -176,6 +176,20 @@ category = "dev" optional = false python-versions = ">=3.5" +[[package]] +name = "flake8" +version = "3.9.2" +description = "the modular source code checker: pep8 pyflakes and co" +category = "dev" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" + +[package.dependencies] +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} +mccabe = ">=0.6.0,<0.7.0" +pycodestyle = ">=2.7.0,<2.8.0" +pyflakes = ">=2.3.0,<2.4.0" + [[package]] name = "ghp-import" version = "2.0.1" @@ -237,7 +251,7 @@ toml = {version = ">=0.10.2", markers = "python_version > \"3.6\""} [[package]] name = "ipython" -version = "7.24.1" +version = "7.25.0" description = "IPython: Productive Interactive Computing" category = "dev" optional = false @@ -381,6 +395,14 @@ python-versions = ">=3.5" [package.dependencies] traitlets = "*" +[[package]] +name = "mccabe" +version = "0.6.1" +description = "McCabe checker, plugin for flake8" +category = "dev" +optional = false +python-versions = "*" + [[package]] name = "mergedeep" version = "1.3.4" @@ -543,6 +565,14 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +[[package]] +name = "pycodestyle" +version = "2.7.0" +description = "Python style guide checker" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + [[package]] name = "pycparser" version = "2.20" @@ -575,6 +605,18 @@ category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" +[[package]] +name = "pyproject-flake8" +version = "0.0.1a2" +description = "pyproject-flake8 (`pflake8`), a monkey patching wrapper to connect flake8 with pyproject.toml configuration" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +flake8 = "*" +toml = "*" + [[package]] name = "pytest" version = "6.2.4" @@ -775,7 +817,7 @@ pytz = "*" [[package]] name = "watchdog" -version = "2.1.2" +version = "2.1.3" description = "Filesystem events monitoring" category = "dev" optional = false @@ -832,7 +874,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pyt [metadata] lock-version = "1.1" python-versions = ">=3.7.0, <3.10" -content-hash = "d9a47064f2050860c955a0871b2bd8899c2f24aaf6482f6a742316fd1fd95ba3" +content-hash = "5be8c38e248b64ff4f2eacf253411b57c91352523c40674f1dec6d8c304996c2" [metadata.files] ansiwrap = [ @@ -852,7 +894,7 @@ argcomplete = [ {file = "argcomplete-1.12.3.tar.gz", hash = "sha256:2c7dbffd8c045ea534921e63b0be6fe65e88599990d8dc408ac8c542b72a5445"}, ] asteval = [ - {file = "asteval-0.9.23.tar.gz", hash = "sha256:f5096a924b1d2f147e70327245d95fc8f534dbe94277b6828ce2a8c049d3a438"}, + {file = "asteval-0.9.25.tar.gz", hash = "sha256:bea22b7d8fa16bcba95ebc72052ae5d8ca97114c9959bb47f8b8eebf30e4342f"}, ] atomicwrites = [ {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, @@ -939,6 +981,10 @@ decorator = [ {file = "decorator-5.0.9-py3-none-any.whl", hash = "sha256:6e5c199c16f7a9f0e3a61a4a54b3d27e7dad0dbdde92b944426cb20914376323"}, {file = "decorator-5.0.9.tar.gz", hash = "sha256:72ecfba4320a893c53f9706bebb2d55c270c1e51a28789361aa93e4a21319ed5"}, ] +flake8 = [ + {file = "flake8-3.9.2-py2.py3-none-any.whl", hash = "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907"}, + {file = "flake8-3.9.2.tar.gz", hash = "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b"}, +] ghp-import = [ {file = "ghp-import-2.0.1.tar.gz", hash = "sha256:753de2eace6e0f7d4edfb3cce5e3c3b98cd52aadb80163303d1d036bda7b4483"}, ] @@ -957,8 +1003,8 @@ ipdb = [ {file = "ipdb-0.13.9.tar.gz", hash = "sha256:951bd9a64731c444fd907a5ce268543020086a697f6be08f7cc2c9a752a278c5"}, ] ipython = [ - {file = "ipython-7.24.1-py3-none-any.whl", hash = "sha256:d513e93327cf8657d6467c81f1f894adc125334ffe0e4ddd1abbb1c78d828703"}, - {file = "ipython-7.24.1.tar.gz", hash = "sha256:9bc24a99f5d19721fb8a2d1408908e9c0520a17fff2233ffe82620847f17f1b6"}, + {file = "ipython-7.25.0-py3-none-any.whl", hash = "sha256:aa21412f2b04ad1a652e30564fff6b4de04726ce875eab222c8430edc6db383a"}, + {file = "ipython-7.25.0.tar.gz", hash = "sha256:54bbd1fe3882457aaf28ae060a5ccdef97f212a741754e420028d4ec5c2291dc"}, ] ipython-genutils = [ {file = "ipython_genutils-0.2.0-py2.py3-none-any.whl", hash = "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8"}, @@ -1027,6 +1073,10 @@ matplotlib-inline = [ {file = "matplotlib-inline-0.1.2.tar.gz", hash = "sha256:f41d5ff73c9f5385775d5c0bc13b424535c8402fe70ea8210f93e11f3683993e"}, {file = "matplotlib_inline-0.1.2-py3-none-any.whl", hash = "sha256:5cf1176f554abb4fa98cb362aa2b55c500147e4bdbb07e3fda359143e1da0811"}, ] +mccabe = [ + {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, + {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, +] mergedeep = [ {file = "mergedeep-1.3.4-py3-none-any.whl", hash = "sha256:70775750742b25c0d8f36c55aed03d24c3384d17c951b3175d898bd778ef0307"}, {file = "mergedeep-1.3.4.tar.gz", hash = "sha256:0096d52e9dad9939c3d975a774666af186eda617e6ca84df4c94dec30004f2a8"}, @@ -1086,6 +1136,10 @@ py = [ {file = "py-1.10.0-py2.py3-none-any.whl", hash = "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a"}, {file = "py-1.10.0.tar.gz", hash = "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3"}, ] +pycodestyle = [ + {file = "pycodestyle-2.7.0-py2.py3-none-any.whl", hash = "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068"}, + {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"}, +] pycparser = [ {file = "pycparser-2.20-py2.py3-none-any.whl", hash = "sha256:7582ad22678f0fcd81102833f60ef8d0e57288b6b5fb00323d101be910e35705"}, {file = "pycparser-2.20.tar.gz", hash = "sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0"}, @@ -1102,6 +1156,10 @@ pyparsing = [ {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, ] +pyproject-flake8 = [ + {file = "pyproject-flake8-0.0.1a2.tar.gz", hash = "sha256:bdeca37f78ecd34bd64a49d3657d53d099f5445831071a31c46e1fe20cd61461"}, + {file = "pyproject_flake8-0.0.1a2-py2.py3-none-any.whl", hash = "sha256:e61ed1dc088e9f9f8a7170967ac4ec135acfef3a59ab9738c7b58cc11f294a7e"}, +] pytest = [ {file = "pytest-6.2.4-py3-none-any.whl", hash = "sha256:91ef2131a9bd6be8f76f1f08eac5c5317221d6ad1e143ae03894b862e8976890"}, {file = "pytest-6.2.4.tar.gz", hash = "sha256:50bcad0a0b9c5a72c8e4e7c9855a3ad496ca6a881a3641b4260605450772c54b"}, @@ -1264,23 +1322,27 @@ tzlocal = [ {file = "tzlocal-2.1.tar.gz", hash = "sha256:643c97c5294aedc737780a49d9df30889321cbe1204eac2c2ec6134035a92e44"}, ] watchdog = [ - {file = "watchdog-2.1.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:581e3548159fe7d2a9f377a1fbcb41bdcee46849cca8ab803c7ac2e5e04ec77c"}, - {file = "watchdog-2.1.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:edcd9ef3fd460bb8a98eb1fcf99941e9fd9f275f45f1a82cb1359ec92975d647"}, - {file = "watchdog-2.1.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d34ce2261f118ecd57eedeef95fc2a495fc4a40b3ed7b3bf0bd7a8ccc1ab4f8f"}, - {file = "watchdog-2.1.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:668391e6c32742d76e5be5db6bf95c455fa4b3d11e76a77c13b39bccb3a47a72"}, - {file = "watchdog-2.1.2-pp36-pypy36_pp73-macosx_10_9_x86_64.whl", hash = "sha256:6ef9fe57162c4c361692620e1d9167574ba1975ee468b24051ca11c9bba6438e"}, - {file = "watchdog-2.1.2-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:58ebb1095ee493008a7789d47dd62e4999505d82be89fc884d473086fccc6ebd"}, - {file = "watchdog-2.1.2-py3-none-manylinux2014_aarch64.whl", hash = "sha256:91387ee2421f30b75f7ff632c9d48f76648e56bf346a7c805c0a34187a93aab4"}, - {file = "watchdog-2.1.2-py3-none-manylinux2014_armv7l.whl", hash = "sha256:a6471517315a8541a943c00b45f1d252e36898a3ae963d2d52509b89a50cb2b9"}, - {file = "watchdog-2.1.2-py3-none-manylinux2014_i686.whl", hash = "sha256:a42e6d652f820b2b94cd03156c62559a2ea68d476476dfcd77d931e7f1012d4a"}, - {file = "watchdog-2.1.2-py3-none-manylinux2014_ppc64.whl", hash = "sha256:3d6405681471ebe0beb3aa083998c4870e48b57f8afdb45ea1b5957cc5cf1014"}, - {file = "watchdog-2.1.2-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:598d772beeaf9c98d0df946fbabf0c8365dd95ea46a250c224c725fe0c4730bc"}, - {file = "watchdog-2.1.2-py3-none-manylinux2014_s390x.whl", hash = "sha256:4b219d46d89cfa49af1d73175487c14a318a74cb8c5442603fd13c6a5b418c86"}, - {file = "watchdog-2.1.2-py3-none-manylinux2014_x86_64.whl", hash = "sha256:188145185c08c73c56f1478ccf1f0f0f85101191439679b35b6b100886ce0b39"}, - {file = "watchdog-2.1.2-py3-none-win32.whl", hash = "sha256:255a32d44bbbe62e52874ff755e2eefe271b150e0ec240ad7718a62a7a7a73c4"}, - {file = "watchdog-2.1.2-py3-none-win_amd64.whl", hash = "sha256:1a62a4671796dc93d1a7262286217d9e75823c63d4c42782912d39a506d30046"}, - {file = "watchdog-2.1.2-py3-none-win_ia64.whl", hash = "sha256:104266a778906ae0e971368d368a65c4cd032a490a9fca5ba0b78c6c7ae11720"}, - {file = "watchdog-2.1.2.tar.gz", hash = "sha256:0237db4d9024859bea27d0efb59fe75eef290833fd988b8ead7a879b0308c2db"}, + {file = "watchdog-2.1.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:9628f3f85375a17614a2ab5eac7665f7f7be8b6b0a2a228e6f6a2e91dd4bfe26"}, + {file = "watchdog-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:acc4e2d5be6f140f02ee8590e51c002829e2c33ee199036fcd61311d558d89f4"}, + {file = "watchdog-2.1.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:85b851237cf3533fabbc034ffcd84d0fa52014b3121454e5f8b86974b531560c"}, + {file = "watchdog-2.1.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a12539ecf2478a94e4ba4d13476bb2c7a2e0a2080af2bb37df84d88b1b01358a"}, + {file = "watchdog-2.1.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:6fe9c8533e955c6589cfea6f3f0a1a95fb16867a211125236c82e1815932b5d7"}, + {file = "watchdog-2.1.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:d9456f0433845e7153b102fffeb767bde2406b76042f2216838af3b21707894e"}, + {file = "watchdog-2.1.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:fd8c595d5a93abd441ee7c5bb3ff0d7170e79031520d113d6f401d0cf49d7c8f"}, + {file = "watchdog-2.1.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0bcfe904c7d404eb6905f7106c54873503b442e8e918cc226e1828f498bdc0ca"}, + {file = "watchdog-2.1.3-pp36-pypy36_pp73-macosx_10_9_x86_64.whl", hash = "sha256:bf84bd94cbaad8f6b9cbaeef43080920f4cb0e61ad90af7106b3de402f5fe127"}, + {file = "watchdog-2.1.3-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:b8ddb2c9f92e0c686ea77341dcb58216fa5ff7d5f992c7278ee8a392a06e86bb"}, + {file = "watchdog-2.1.3-py3-none-manylinux2014_aarch64.whl", hash = "sha256:8805a5f468862daf1e4f4447b0ccf3acaff626eaa57fbb46d7960d1cf09f2e6d"}, + {file = "watchdog-2.1.3-py3-none-manylinux2014_armv7l.whl", hash = "sha256:3e305ea2757f81d8ebd8559d1a944ed83e3ab1bdf68bcf16ec851b97c08dc035"}, + {file = "watchdog-2.1.3-py3-none-manylinux2014_i686.whl", hash = "sha256:431a3ea70b20962e6dee65f0eeecd768cd3085ea613ccb9b53c8969de9f6ebd2"}, + {file = "watchdog-2.1.3-py3-none-manylinux2014_ppc64.whl", hash = "sha256:e4929ac2aaa2e4f1a30a36751160be391911da463a8799460340901517298b13"}, + {file = "watchdog-2.1.3-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:201cadf0b8c11922f54ec97482f95b2aafca429c4c3a4bb869a14f3c20c32686"}, + {file = "watchdog-2.1.3-py3-none-manylinux2014_s390x.whl", hash = "sha256:3a7d242a7963174684206093846537220ee37ba9986b824a326a8bb4ef329a33"}, + {file = "watchdog-2.1.3-py3-none-manylinux2014_x86_64.whl", hash = "sha256:54e057727dd18bd01a3060dbf5104eb5a495ca26316487e0f32a394fd5fe725a"}, + {file = "watchdog-2.1.3-py3-none-win32.whl", hash = "sha256:b5fc5c127bad6983eecf1ad117ab3418949f18af9c8758bd10158be3647298a9"}, + {file = "watchdog-2.1.3-py3-none-win_amd64.whl", hash = "sha256:44acad6f642996a2b50bb9ce4fb3730dde08f23e79e20cd3d8e2a2076b730381"}, + {file = "watchdog-2.1.3-py3-none-win_ia64.whl", hash = "sha256:0bcdf7b99b56a3ae069866c33d247c9994ffde91b620eaf0306b27e099bd1ae0"}, + {file = "watchdog-2.1.3.tar.gz", hash = "sha256:e5236a8e8602ab6db4b873664c2d356c365ab3cac96fbdec4970ad616415dd45"}, ] wcwidth = [ {file = "wcwidth-0.2.5-py2.py3-none-any.whl", hash = "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784"}, diff --git a/pyproject.toml b/pyproject.toml index 2719b954..36bc3d13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,12 +48,12 @@ behave = "^1.2" mkdocs = "^1.0" black = {version = "^21.5b2",allow-prereleases = true} toml = ">=0.10" -pyflakes = ">=2.2.0" pytest = ">=6.2" pytest-bdd = "^4.0.1" yq = ">=2.11" ipdb = ">=0.13" pytest-clarity = "^0.3.0-alpha.0" +pyproject-flake8 = "^0.0.1-alpha.2" [tool.poetry.scripts] jrnl = 'jrnl.cli:cli' @@ -84,6 +84,10 @@ filterwarnings = [ "ignore:[WinError 5].*" ] +[tool.flake8] +# ignore formatting warnings and errors because we use Black to autoformat +extend-ignore = "E101,E111,E114,E115,E116,E117,E12,E13,E2,E3,E401,E5,E70,W1,W2,W3,W5" + [build-system] requires = ["poetry>=1.1"] build-backend = "poetry.masonry.api" diff --git a/tests/step_defs/conftest.py b/tests/step_defs/conftest.py index d73fcec4..a3021972 100644 --- a/tests/step_defs/conftest.py +++ b/tests/step_defs/conftest.py @@ -1,13 +1,17 @@ # Copyright (C) 2012-2021 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html -from jrnl.os_compat import on_windows from pytest import mark -from .fixtures import * -from .given_steps import * -from .when_steps import * -from .then_steps import * +from jrnl.os_compat import on_windows + + +pytest_plugins = [ + "tests.step_defs.fixtures", + "tests.step_defs.given_steps", + "tests.step_defs.when_steps", + "tests.step_defs.then_steps", +] def pytest_bdd_apply_tag(tag, function): diff --git a/tests/step_defs/fixtures.py b/tests/step_defs/fixtures.py index a8e243ae..a93a7e43 100644 --- a/tests/step_defs/fixtures.py +++ b/tests/step_defs/fixtures.py @@ -1,14 +1,14 @@ # Copyright (C) 2012-2021 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html -import os from collections import defaultdict -from keyring import backend -from keyring import set_keyring -from keyring import errors +import os from pathlib import Path import tempfile +from keyring import backend +from keyring import errors +from keyring import set_keyring from pytest import fixture import toml @@ -59,7 +59,7 @@ class NoKeyring(backend.KeyringBackend): class FailedKeyring(backend.KeyringBackend): - """ A keyring that cannot be retrieved. """ + """A keyring that cannot be retrieved.""" priority = 2 @@ -192,11 +192,10 @@ def editor(editor_state): Path(tmpfile).touch() with open(tmpfile, editor_state["intent"]["method"]) as f: # Touch the file so jrnl knows it was edited - if editor_state["intent"]["input"] != None: + if editor_state["intent"]["input"] is not None: f.write(editor_state["intent"]["input"]) file_content = f.read() editor_state["tmpfile"]["content"] = file_content return _mock_editor - diff --git a/tests/step_defs/given_steps.py b/tests/step_defs/given_steps.py index 8db8fa1c..649d44c5 100644 --- a/tests/step_defs/given_steps.py +++ b/tests/step_defs/given_steps.py @@ -1,22 +1,23 @@ # Copyright (C) 2012-2021 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html +from datetime import datetime import json import os -from datetime import datetime -from keyring import set_keyring import random -import string import shutil -from unittest.mock import patch +import string from unittest.mock import MagicMock +from unittest.mock import patch from xml.etree import ElementTree +from keyring import set_keyring +from pytest_bdd import given +from pytest_bdd.parsers import parse + from jrnl import __version__ from jrnl.time import __get_pdt_calendar -from pytest_bdd import given -from pytest_bdd.parsers import parse from .fixtures import FailedKeyring from .fixtures import TestKeyring diff --git a/tests/step_defs/helpers.py b/tests/step_defs/helpers.py index e2ea91c9..7d089597 100644 --- a/tests/step_defs/helpers.py +++ b/tests/step_defs/helpers.py @@ -4,7 +4,6 @@ import os - def does_directory_contain_files(file_list, directory_path): if not os.path.isdir(directory_path): return False diff --git a/tests/step_defs/then_steps.py b/tests/step_defs/then_steps.py index 4bcf1c56..b56c203f 100644 --- a/tests/step_defs/then_steps.py +++ b/tests/step_defs/then_steps.py @@ -4,17 +4,17 @@ import json import os import re -import yaml from xml.etree import ElementTree from pytest_bdd import then from pytest_bdd.parsers import parse +import yaml from jrnl.config import scope_config -from .helpers import parse_should_or_should_not -from .helpers import does_directory_contain_files from .helpers import assert_equal_tags_ignoring_order +from .helpers import does_directory_contain_files +from .helpers import parse_should_or_should_not @then("we should get no error") diff --git a/tests/step_defs/when_steps.py b/tests/step_defs/when_steps.py index a80d7525..2e72173b 100644 --- a/tests/step_defs/when_steps.py +++ b/tests/step_defs/when_steps.py @@ -1,13 +1,13 @@ # Copyright (C) 2012-2021 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html -import os from contextlib import ExitStack +import os from unittest.mock import patch +from pytest_bdd import parsers from pytest_bdd import when from pytest_bdd.parsers import parse -from pytest_bdd import parsers from jrnl.cli import cli from jrnl.os_compat import split_args diff --git a/tests/unit/test_color.py b/tests/unit/test_color.py index 14dc7938..527b8e89 100644 --- a/tests/unit/test_color.py +++ b/tests/unit/test_color.py @@ -1,7 +1,8 @@ +from colorama import Fore +from colorama import Style import pytest from jrnl.color import colorize -from colorama import Fore, Style @pytest.fixture() diff --git a/tests/unit/test_display.py b/tests/unit/test_display.py index 72a9c451..921d1631 100644 --- a/tests/unit/test_display.py +++ b/tests/unit/test_display.py @@ -1,7 +1,9 @@ import argparse -import jrnl -import pytest from unittest import mock + +import pytest + +import jrnl from jrnl.jrnl import _display_search_results diff --git a/tests/unit/test_export.py b/tests/unit/test_export.py index 0f494f79..8bc1b410 100644 --- a/tests/unit/test_export.py +++ b/tests/unit/test_export.py @@ -1,8 +1,8 @@ +import pytest + from jrnl.exception import JrnlError from jrnl.plugins.fancy_exporter import check_provided_linewrap_viability -import pytest - @pytest.fixture() def datestr(): diff --git a/tests/unit/test_install.py b/tests/unit/test_install.py index 31ec150c..bc36b927 100644 --- a/tests/unit/test_install.py +++ b/tests/unit/test_install.py @@ -1,6 +1,7 @@ -from unittest import mock -import pytest import sys +from unittest import mock + +import pytest @pytest.mark.filterwarnings( diff --git a/tests/unit/test_os_compat.py b/tests/unit/test_os_compat.py index f7c058f1..02d54716 100644 --- a/tests/unit/test_os_compat.py +++ b/tests/unit/test_os_compat.py @@ -1,8 +1,9 @@ from unittest import mock + import pytest -from jrnl.os_compat import on_windows from jrnl.os_compat import on_posix +from jrnl.os_compat import on_windows from jrnl.os_compat import split_args diff --git a/tests/unit/test_override.py b/tests/unit/test_override.py index 32ec0595..d22709f4 100644 --- a/tests/unit/test_override.py +++ b/tests/unit/test_override.py @@ -1,12 +1,10 @@ import pytest -from jrnl.override import ( - apply_overrides, - _recursively_apply, - _get_config_node, - _get_key_and_value_from_pair, - _convert_dots_to_list, -) +from jrnl.override import _convert_dots_to_list +from jrnl.override import _get_config_node +from jrnl.override import _get_key_and_value_from_pair +from jrnl.override import _recursively_apply +from jrnl.override import apply_overrides @pytest.fixture() @@ -56,7 +54,7 @@ def test_recursively_apply(): def test_get_config_node(minimal_config): assert len(minimal_config.keys()) == 4 assert _get_config_node(minimal_config, "editor") == "vim" - assert _get_config_node(minimal_config, "display_format") == None + assert _get_config_node(minimal_config, "display_format") is None def test_get_kv_from_pair(): diff --git a/tests/unit/test_parse_args.py b/tests/unit/test_parse_args.py index 4b140fc1..0725d33d 100644 --- a/tests/unit/test_parse_args.py +++ b/tests/unit/test_parse_args.py @@ -283,10 +283,10 @@ class TestDeserialization: assert cfg["linewrap"] == 23 cfg = make_yaml_valid_dict(["encrypt", "false"]) - assert cfg["encrypt"] == False + assert cfg["encrypt"] is False cfg = make_yaml_valid_dict(["editor", "vi -c startinsert"]) assert cfg["editor"] == "vi -c startinsert" cfg = make_yaml_valid_dict(["highlight", "true"]) - assert cfg["highlight"] == True + assert cfg["highlight"] is True