diff --git a/poetry.lock b/poetry.lock index a7866ad..7c8e66b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -19,6 +19,52 @@ wrapt = [ {version = ">=1.14,<2", markers = "python_version >= \"3.11\""}, ] +[[package]] +name = "black" +version = "23.7.0" +description = "The uncompromising code formatter." +optional = false +python-versions = ">=3.8" +files = [ + {file = "black-23.7.0-cp310-cp310-macosx_10_16_arm64.whl", hash = "sha256:5c4bc552ab52f6c1c506ccae05681fab58c3f72d59ae6e6639e8885e94fe2587"}, + {file = "black-23.7.0-cp310-cp310-macosx_10_16_universal2.whl", hash = "sha256:552513d5cd5694590d7ef6f46e1767a4df9af168d449ff767b13b084c020e63f"}, + {file = "black-23.7.0-cp310-cp310-macosx_10_16_x86_64.whl", hash = "sha256:86cee259349b4448adb4ef9b204bb4467aae74a386bce85d56ba4f5dc0da27be"}, + {file = "black-23.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:501387a9edcb75d7ae8a4412bb8749900386eaef258f1aefab18adddea1936bc"}, + {file = "black-23.7.0-cp310-cp310-win_amd64.whl", hash = "sha256:fb074d8b213749fa1d077d630db0d5f8cc3b2ae63587ad4116e8a436e9bbe995"}, + {file = "black-23.7.0-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:b5b0ee6d96b345a8b420100b7d71ebfdd19fab5e8301aff48ec270042cd40ac2"}, + {file = "black-23.7.0-cp311-cp311-macosx_10_16_universal2.whl", hash = "sha256:893695a76b140881531062d48476ebe4a48f5d1e9388177e175d76234ca247cd"}, + {file = "black-23.7.0-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:c333286dc3ddca6fdff74670b911cccedacb4ef0a60b34e491b8a67c833b343a"}, + {file = "black-23.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:831d8f54c3a8c8cf55f64d0422ee875eecac26f5f649fb6c1df65316b67c8926"}, + {file = "black-23.7.0-cp311-cp311-win_amd64.whl", hash = "sha256:7f3bf2dec7d541b4619b8ce526bda74a6b0bffc480a163fed32eb8b3c9aed8ad"}, + {file = "black-23.7.0-cp38-cp38-macosx_10_16_arm64.whl", hash = "sha256:f9062af71c59c004cd519e2fb8f5d25d39e46d3af011b41ab43b9c74e27e236f"}, + {file = "black-23.7.0-cp38-cp38-macosx_10_16_universal2.whl", hash = "sha256:01ede61aac8c154b55f35301fac3e730baf0c9cf8120f65a9cd61a81cfb4a0c3"}, + {file = "black-23.7.0-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:327a8c2550ddc573b51e2c352adb88143464bb9d92c10416feb86b0f5aee5ff6"}, + {file = "black-23.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d1c6022b86f83b632d06f2b02774134def5d4d4f1dac8bef16d90cda18ba28a"}, + {file = "black-23.7.0-cp38-cp38-win_amd64.whl", hash = "sha256:27eb7a0c71604d5de083757fbdb245b1a4fae60e9596514c6ec497eb63f95320"}, + {file = "black-23.7.0-cp39-cp39-macosx_10_16_arm64.whl", hash = "sha256:8417dbd2f57b5701492cd46edcecc4f9208dc75529bcf76c514864e48da867d9"}, + {file = "black-23.7.0-cp39-cp39-macosx_10_16_universal2.whl", hash = "sha256:47e56d83aad53ca140da0af87678fb38e44fd6bc0af71eebab2d1f59b1acf1d3"}, + {file = "black-23.7.0-cp39-cp39-macosx_10_16_x86_64.whl", hash = "sha256:25cc308838fe71f7065df53aedd20327969d05671bac95b38fdf37ebe70ac087"}, + {file = "black-23.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:642496b675095d423f9b8448243336f8ec71c9d4d57ec17bf795b67f08132a91"}, + {file = "black-23.7.0-cp39-cp39-win_amd64.whl", hash = "sha256:ad0014efc7acf0bd745792bd0d8857413652979200ab924fbf239062adc12491"}, + {file = "black-23.7.0-py3-none-any.whl", hash = "sha256:9fd59d418c60c0348505f2ddf9609c1e1de8e7493eab96198fc89d9f865e7a96"}, + {file = "black-23.7.0.tar.gz", hash = "sha256:022a582720b0d9480ed82576c920a8c1dde97cc38ff11d8d8859b3bd6ca9eedb"}, +] + +[package.dependencies] +click = ">=8.0.0" +mypy-extensions = ">=0.4.3" +packaging = ">=22.0" +pathspec = ">=0.9.0" +platformdirs = ">=2" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} + +[package.extras] +colorama = ["colorama (>=0.4.3)"] +d = ["aiohttp (>=3.7.4)"] +jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] +uvloop = ["uvloop (>=0.15.2)"] + [[package]] name = "certifi" version = "2023.7.22" @@ -125,6 +171,20 @@ files = [ {file = "charset_normalizer-3.2.0-py3-none-any.whl", hash = "sha256:8e098148dd37b4ce3baca71fb394c81dc5d9c7728c95df695d2dca218edf40e6"}, ] +[[package]] +name = "click" +version = "8.1.6" +description = "Composable command line interface toolkit" +optional = false +python-versions = ">=3.7" +files = [ + {file = "click-8.1.6-py3-none-any.whl", hash = "sha256:fa244bb30b3b5ee2cae3da8f55c9e5e0c0e86093306301fb418eb9dc40fbded5"}, + {file = "click-8.1.6.tar.gz", hash = "sha256:48ee849951919527a045bfe3bf7baa8a959c423134e1a5b98c05c20ba75a1cbd"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + [[package]] name = "colorama" version = "0.4.6" @@ -459,6 +519,17 @@ files = [ {file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"}, ] +[[package]] +name = "pathspec" +version = "0.11.2" +description = "Utility library for gitignore style pattern matching of file paths." +optional = false +python-versions = ">=3.7" +files = [ + {file = "pathspec-0.11.2-py3-none-any.whl", hash = "sha256:1d6ed233af05e679efb96b1851550ea95bbb64b7c490b0f5aa52996c11e92a20"}, + {file = "pathspec-0.11.2.tar.gz", hash = "sha256:e0d8d0ac2f12da61956eb2306b69f9469b42f4deb0f3cb6ed47b9cce9996ced3"}, +] + [[package]] name = "platformdirs" version = "3.10.0" @@ -934,4 +1005,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "ff3839fd7cf8c94c2e689bc3015cc3462aa9efe15b8c8dcef26203af894e0984" +content-hash = "87e3faef6c02c5eb7ba64188137d6fe823b60177748c5df84f4fec80ed0cf692" diff --git a/pyproject.toml b/pyproject.toml index d6b8a36..52f3689 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ toml = "^0.10.2" [tool.poetry.dev-dependencies] pre-commit = "^3.3.3" +black = "^23.7.0" isort = "^5.12.0" pytest = "^7.4.0" pytest-cov = "^4.1.0" @@ -46,6 +47,18 @@ types-termcolor = "^1.1.6.2" types-toml = "^0.10.8.7" types-requests = "^2.31.0.2" +[tool.isort] +src_paths = ["lancini", "test"] +profile = "black" +line_length = 90 + +[tool.mypy] +warn_return_any = true +warn_unused_configs = true + +[tool.pylint.FORMAT] +max-line-length=90 + [tool.poetry.scripts] oneup = 'oneup.cli:main' diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..266ac25 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,9 @@ +[flake8] +exclude = + .git, + __pycache__, + build, + dist, + env +max-complexity = 10 +max-line-length = 90 diff --git a/tests/test_cli.py b/tests/test_cli.py index f91f9f5..beab635 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -6,7 +6,6 @@ from typing import Final import pytest - from oneup import cli SAMPLE_FILES_PATH: Final[Path] = Path("tests/sample_files") @@ -24,9 +23,7 @@ def test_get_parser() -> None: assert parser.epilog == "Happy coding! :-)" -def test_discover_all_requirement_files( - monkeypatch: pytest.MonkeyPatch -) -> None: +def test_discover_all_requirement_files(monkeypatch: pytest.MonkeyPatch) -> None: """ Unit tests that make sure that file discovery is working as expected. """ @@ -39,31 +36,13 @@ def test_discover_all_requirement_files( monkeypatch.setattr("os.listdir", lambda: ["test", "another_test.txt"]) assert cli.discover_all_requirement_files() == [] - monkeypatch.setattr( - "os.listdir", - lambda: [ - "requirements.txt", - "another_test.txt" - ] - ) + monkeypatch.setattr("os.listdir", lambda: ["requirements.txt", "another_test.txt"]) assert cli.discover_all_requirement_files() == [Path("requirements.txt")] - monkeypatch.setattr( - "os.listdir", - lambda: [ - "pyproject.toml", - "another_test.txt" - ] - ) + monkeypatch.setattr("os.listdir", lambda: ["pyproject.toml", "another_test.txt"]) assert cli.discover_all_requirement_files() == [Path("pyproject.toml")] - monkeypatch.setattr( - "os.listdir", - lambda: [ - "pyproject.toml", - "requirements.txt" - ] - ) + monkeypatch.setattr("os.listdir", lambda: ["pyproject.toml", "requirements.txt"]) assert cli.discover_all_requirement_files() == [ Path("pyproject.toml"), Path("requirements.txt"), @@ -77,7 +56,7 @@ def test_discover_all_requirement_files( "this is not a requirements file.txt", "not requirements.txt", "definitely not a pyproject.toml", - ] + ], ) assert cli.discover_all_requirement_files() == [] @@ -104,18 +83,12 @@ def test_discover_requirement_file(monkeypatch: pytest.MonkeyPatch) -> None: is behaving properly """ - monkeypatch.setattr( - cli, - "discover_all_requirement_files", - lambda: None - ) + monkeypatch.setattr(cli, "discover_all_requirement_files", lambda: None) assert cli.discover_requirement_file(True) is None assert cli.discover_requirement_file(False) is None monkeypatch.setattr( - cli, - "discover_all_requirement_files", - lambda: [Path("requirements.txt")] + cli, "discover_all_requirement_files", lambda: [Path("requirements.txt")] ) assert cli.discover_requirement_file(True) == Path("requirements.txt") assert cli.discover_requirement_file(False) == Path("requirements.txt") @@ -123,24 +96,15 @@ def test_discover_requirement_file(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr( cli, "discover_all_requirement_files", - lambda: [Path("requirements.txt"), Path("pyproject.toml")] - ) - assert ( - cli.discover_requirement_file(False) - == Path("requirements.txt") + lambda: [Path("requirements.txt"), Path("pyproject.toml")], ) + assert cli.discover_requirement_file(False) == Path("requirements.txt") - monkeypatch.setattr('builtins.input', lambda _: "0") - assert ( - cli.discover_requirement_file(True) - == Path("requirements.txt") - ) + monkeypatch.setattr("builtins.input", lambda _: "0") + assert cli.discover_requirement_file(True) == Path("requirements.txt") - monkeypatch.setattr('builtins.input', lambda _: "1") - assert ( - cli.discover_requirement_file(True) - == Path("pyproject.toml") - ) + monkeypatch.setattr("builtins.input", lambda _: "1") + assert cli.discover_requirement_file(True) == Path("pyproject.toml") def test_get_dependencies_from_pyproject_file() -> None: @@ -213,13 +177,15 @@ def test_get_dependencies_from_pyproject_file() -> None: "dev-dependencies": { "package3": "1.2.3", "package4": "4.5.6", - } + }, } } } ) == ["package1", "package2", "package3", "package4"] - assert cli.get_dependencies_from_pyproject_file({}) == [] + output = cli.get_dependencies_from_pyproject_file({}) + expected: list[str] = [] + assert output == expected def test_scan_file(monkeypatch: pytest.MonkeyPatch) -> None: @@ -234,8 +200,9 @@ def mock_print_project_latest_version_and_url(dependency: str) -> None: printed_dependencies.append(dependency) monkeypatch.setattr( - cli, "print_project_latest_version_and_url", - mock_print_project_latest_version_and_url + cli, + "print_project_latest_version_and_url", + mock_print_project_latest_version_and_url, ) # case: requirements.txt diff --git a/tests/test_oneup.py b/tests/test_oneup.py index 63e6faf..ab82ab8 100644 --- a/tests/test_oneup.py +++ b/tests/test_oneup.py @@ -1,5 +1,13 @@ +""" +Collection of sanity tests for oneup module. +""" + from oneup import __version__ def test_version(): - assert __version__ == '0.2.0' + """ + Tests that the oneup module is set to the correct version + """ + + assert __version__ == "0.2.0"