diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml index e473c1b..712ff78 100644 --- a/.github/workflows/code-check.yml +++ b/.github/workflows/code-check.yml @@ -25,4 +25,12 @@ jobs: - name: Verify generated ownership files run: poetry run python scripts/sync_ownership.py --check - - uses: pre-commit/action@v3.0.1 + - name: Show quality tool versions + run: | + poetry run black --version + poetry run isort --version-number + poetry run yamlfix --version + poetry run pre-commit --version + + - name: Run pre-commit checks + run: poetry run pre-commit run --all-files --show-diff-on-failure diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4bfb3f3..58b5ad6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ Once you have the repository on your system you can proceed: 1. `poetry install` - Installs required packages setup in [pyproject.toml](/pyproject.toml) 1. To validate poetry/`pyproject.toml` you can run: `poetry check` 2. `poetry run pre-commit install` - Sets up black and other configurations using [.pre-commit-config.yaml](/.pre-commit-config.yaml) in `.git/hooks` - 1. You can test all files with `poetry run pre-commit run --all-files` + 1. You can test all files with `poetry run pre-commit run --all-files --show-diff-on-failure` 3. `python -m pip install -e .` - This adds cwms-cli and it's commands to your local path allowing you to live develop cwms-cli as a package and test the CLI functions on your system. 4. Run `cwms-cli` to confirm everything installed! @@ -82,7 +82,15 @@ Contributor expectation for `csv2cwms`: ## Formatting -Formatting of code is done via black. You must ensure you have walked through the getting start to setup the `pre-commit` steps for black to match this repositories style practices. +Formatting of code is done via black through the configured `pre-commit` hooks. Run `poetry install --with dev --no-interaction` before quality checks so local tools use the versions locked for this repository. + +Before pushing, run: + +```shell +poetry run pre-commit run --all-files --show-diff-on-failure +``` + +This command may rewrite files if formatting has drifted. Run it from a clean branch or review `git status --short` afterward so you only commit intentional changes. ## Code Review diff --git a/cwmscli/commands/commands_cwms.py b/cwmscli/commands/commands_cwms.py index a2901fc..b076d02 100644 --- a/cwmscli/commands/commands_cwms.py +++ b/cwmscli/commands/commands_cwms.py @@ -492,13 +492,15 @@ def update_cli_cmd(target_version: Optional[str], pre: bool, yes: bool) -> None: @click.group( "blob", help="Manage CWMS Blobs (upload, download, delete, update, list)", - epilog=textwrap.dedent(""" + epilog=textwrap.dedent( + """ Example Usage:\n - Store a PDF/image as a CWMS blob with optional description\n - Download a blob by id to your local filesystem\n - Update a blob's name/description/mime-type\n - Bulk list blobs for an office -"""), +""" + ), ) def blob_group(): pass @@ -706,12 +708,14 @@ def list_cmd(**kwargs): @click.group( "clob", help="Manage CWMS Clobs (upload, download, delete, update, list)", - epilog=textwrap.dedent(""" + epilog=textwrap.dedent( + """ Example Usage:\n - Download a clob by id to your local filesystem\n - Update a clob's name/description/mime-type\n - Bulk list clobs for an office -"""), +""" + ), ) @requires(reqs.cwms) def clob_group(): diff --git a/poetry.lock b/poetry.lock index 726e5fc..cb6520e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.3.2 and should not be changed by hand. [[package]] name = "black" @@ -7,7 +7,6 @@ description = "The uncompromising code formatter." optional = false python-versions = ">=3.9" groups = ["dev"] -markers = "python_version == \"3.9\"" files = [ {file = "black-24.10.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e6668650ea4b685440857138e5fe40cde4d652633b1bdffc62933d0db4ed9812"}, {file = "black-24.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1c536fcf674217e87b8cc3657b81809d3c085d7bf3ef262ead700da345bfa6ea"}, @@ -48,60 +47,6 @@ d = ["aiohttp (>=3.10)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] uvloop = ["uvloop (>=0.15.2)"] -[[package]] -name = "black" -version = "26.5.1" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.10" -groups = ["dev"] -markers = "python_version >= \"3.10\"" -files = [ - {file = "black-26.5.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9942db8888e06943c5dde66ca0037dcff82a2a4ec1ad0ada9e0d2ee9d9823893"}, - {file = "black-26.5.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:89c93167a74d3a75dfaa38a5c7cca015537d5820dd7f17d63267d674a61cae90"}, - {file = "black-26.5.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:22f2cd76d069cc54c71f10360744ba8983fbb616903b4304a85b734915c8e1b4"}, - {file = "black-26.5.1-cp310-cp310-win_amd64.whl", hash = "sha256:87ed5c6f450580a2f6790bc7cbfb016dfc73bc750249762268a3695361315eef"}, - {file = "black-26.5.1-cp310-cp310-win_arm64.whl", hash = "sha256:58b4bd92cf88aacf83d88479c8f9caee044b1ec55f2451a337354a7ea2590a22"}, - {file = "black-26.5.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:96ae2c733b2aabdd9986e2c5df628ff3473676cd1c5faded1ff496cf6d74083c"}, - {file = "black-26.5.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:0e48b87e03bf109288e55cfceadcfa15ff5470aca2851a851950ed2926f450d7"}, - {file = "black-26.5.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5119fa92ae61f786e8c3662fd60aece1d0a2dd5cca5d0c79417a95e7a4272a59"}, - {file = "black-26.5.1-cp311-cp311-win_amd64.whl", hash = "sha256:30d3c14661f2792e9142cce3eeeb1cbc175b3eb5f733be0c8eeb99651e52b0c3"}, - {file = "black-26.5.1-cp311-cp311-win_arm64.whl", hash = "sha256:1ef92b76f7733f282fd096ea406200b5a286c42947412b0eaff3a74e3616cefe"}, - {file = "black-26.5.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4ad6fa01f941920f54f2bbb35f3df7673428a0ef98a0b0840c2eaef3b110efa8"}, - {file = "black-26.5.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3915f256e75a2d7cf88d8953d37f780455dc586cc72dee059c528fe77f581217"}, - {file = "black-26.5.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9d98d4137277c75dfb898ec8d846c4fd68ba1e9cf77f95e2865c203dc18f4c3d"}, - {file = "black-26.5.1-cp312-cp312-win_amd64.whl", hash = "sha256:a1dca32d9f1784af512a13410ec204c6f7f0aa9797a111c42e1c03449821c264"}, - {file = "black-26.5.1-cp312-cp312-win_arm64.whl", hash = "sha256:1037d5ac7b7b310b2632ad867ec8d0e4c4819dcdb0b820f63135da746a24e418"}, - {file = "black-26.5.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:2b36cf2ddf5566e205f6535f782a62194a184d33e175b64ae8c40b1737522be3"}, - {file = "black-26.5.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1f7ea64ebfa01b50f693508fc39f875e264446d3b097088f84f203b9d09618a0"}, - {file = "black-26.5.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ecb3e624844c798144e9bd986954e0adc81d8911a1f30f375e1252fe26e8c294"}, - {file = "black-26.5.1-cp313-cp313-win_amd64.whl", hash = "sha256:e1a26503279b6b310669fb0b219c39e4820b77e8189fe80f522bb511f247db0a"}, - {file = "black-26.5.1-cp313-cp313-win_arm64.whl", hash = "sha256:5c34b25da232ead53a6f335b76dbea124f4d152ad568b9080d6f944bc2b34b52"}, - {file = "black-26.5.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:e88976690a64b0af98312ca958415849cb42423423c5f2ee74af4b49a97a2168"}, - {file = "black-26.5.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:32d5ea7f6c8bdfa6e648326ebca1f02b0764e2a029edc6f8dce2627e19d468c3"}, - {file = "black-26.5.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ea8d16dc41655aa113cd64665e7219446cd7e4ff2248d7178eaa905190c86b18"}, - {file = "black-26.5.1-cp314-cp314-win_amd64.whl", hash = "sha256:577f21094ea469ef92ec1adaf2c9441a226d2144d01a5be2fa823cecf6543e50"}, - {file = "black-26.5.1-cp314-cp314-win_arm64.whl", hash = "sha256:ed1a20af114c301a0269bf01163d51dbef72737fd65f850001e7cbe7f3c7abae"}, - {file = "black-26.5.1-py3-none-any.whl", hash = "sha256:4ed7f7da04046d2e488437170797d3b4a4ad83906683bcb7dfc68b673bbce5e2"}, - {file = "black-26.5.1.tar.gz", hash = "sha256:dd321f668053961824bcc1be1cc1df748b2d7e4fa28086b08331e577b0100a73"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=1.0.0" -platformdirs = ">=2" -pytokens = ">=0.4.0,<0.5.0" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.10)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2) ; sys_platform != \"win32\"", "winloop (>=0.5.0) ; sys_platform == \"win32\""] - [[package]] name = "certifi" version = "2026.2.25" @@ -291,6 +236,7 @@ files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] +markers = {dev = "sys_platform == \"win32\" or platform_system == \"Windows\""} [[package]] name = "cwms-python" @@ -1130,62 +1076,6 @@ platformdirs = ">=4.3.6,<5" docs = ["furo (>=2025.12.19)", "sphinx (>=9.1)", "sphinx-autodoc-typehints (>=3.6.3)", "sphinxcontrib-mermaid (>=2)"] testing = ["covdefaults (>=2.3)", "coverage (>=7.5.4)", "pytest (>=8.3.5)", "pytest-mock (>=3.14)", "setuptools (>=75.1)"] -[[package]] -name = "pytokens" -version = "0.4.1" -description = "A Fast, spec compliant Python 3.14+ tokenizer that runs on older Pythons." -optional = false -python-versions = ">=3.8" -groups = ["dev"] -markers = "python_version >= \"3.10\"" -files = [ - {file = "pytokens-0.4.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2a44ed93ea23415c54f3face3b65ef2b844d96aeb3455b8a69b3df6beab6acc5"}, - {file = "pytokens-0.4.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:add8bf86b71a5d9fb5b89f023a80b791e04fba57960aa790cc6125f7f1d39dfe"}, - {file = "pytokens-0.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:670d286910b531c7b7e3c0b453fd8156f250adb140146d234a82219459b9640c"}, - {file = "pytokens-0.4.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:4e691d7f5186bd2842c14813f79f8884bb03f5995f0575272009982c5ac6c0f7"}, - {file = "pytokens-0.4.1-cp310-cp310-win_amd64.whl", hash = "sha256:27b83ad28825978742beef057bfe406ad6ed524b2d28c252c5de7b4a6dd48fa2"}, - {file = "pytokens-0.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d70e77c55ae8380c91c0c18dea05951482e263982911fc7410b1ffd1dadd3440"}, - {file = "pytokens-0.4.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4a58d057208cb9075c144950d789511220b07636dd2e4708d5645d24de666bdc"}, - {file = "pytokens-0.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b49750419d300e2b5a3813cf229d4e5a4c728dae470bcc89867a9ad6f25a722d"}, - {file = "pytokens-0.4.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:d9907d61f15bf7261d7e775bd5d7ee4d2930e04424bab1972591918497623a16"}, - {file = "pytokens-0.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:ee44d0f85b803321710f9239f335aafe16553b39106384cef8e6de40cb4ef2f6"}, - {file = "pytokens-0.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:140709331e846b728475786df8aeb27d24f48cbcf7bcd449f8de75cae7a45083"}, - {file = "pytokens-0.4.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6d6c4268598f762bc8e91f5dbf2ab2f61f7b95bdc07953b602db879b3c8c18e1"}, - {file = "pytokens-0.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:24afde1f53d95348b5a0eb19488661147285ca4dd7ed752bbc3e1c6242a304d1"}, - {file = "pytokens-0.4.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:5ad948d085ed6c16413eb5fec6b3e02fa00dc29a2534f088d3302c47eb59adf9"}, - {file = "pytokens-0.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:3f901fe783e06e48e8cbdc82d631fca8f118333798193e026a50ce1b3757ea68"}, - {file = "pytokens-0.4.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:8bdb9d0ce90cbf99c525e75a2fa415144fd570a1ba987380190e8b786bc6ef9b"}, - {file = "pytokens-0.4.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5502408cab1cb18e128570f8d598981c68a50d0cbd7c61312a90507cd3a1276f"}, - {file = "pytokens-0.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:29d1d8fb1030af4d231789959f21821ab6325e463f0503a61d204343c9b355d1"}, - {file = "pytokens-0.4.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:970b08dd6b86058b6dc07efe9e98414f5102974716232d10f32ff39701e841c4"}, - {file = "pytokens-0.4.1-cp313-cp313-win_amd64.whl", hash = "sha256:9bd7d7f544d362576be74f9d5901a22f317efc20046efe2034dced238cbbfe78"}, - {file = "pytokens-0.4.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:4a14d5f5fc78ce85e426aa159489e2d5961acf0e47575e08f35584009178e321"}, - {file = "pytokens-0.4.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:97f50fd18543be72da51dd505e2ed20d2228c74e0464e4262e4899797803d7fa"}, - {file = "pytokens-0.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:dc74c035f9bfca0255c1af77ddd2d6ae8419012805453e4b0e7513e17904545d"}, - {file = "pytokens-0.4.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:f66a6bbe741bd431f6d741e617e0f39ec7257ca1f89089593479347cc4d13324"}, - {file = "pytokens-0.4.1-cp314-cp314-win_amd64.whl", hash = "sha256:b35d7e5ad269804f6697727702da3c517bb8a5228afa450ab0fa787732055fc9"}, - {file = "pytokens-0.4.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:8fcb9ba3709ff77e77f1c7022ff11d13553f3c30299a9fe246a166903e9091eb"}, - {file = "pytokens-0.4.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:79fc6b8699564e1f9b521582c35435f1bd32dd06822322ec44afdeba666d8cb3"}, - {file = "pytokens-0.4.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d31b97b3de0f61571a124a00ffe9a81fb9939146c122c11060725bd5aea79975"}, - {file = "pytokens-0.4.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:967cf6e3fd4adf7de8fc73cd3043754ae79c36475c1c11d514fc72cf5490094a"}, - {file = "pytokens-0.4.1-cp314-cp314t-win_amd64.whl", hash = "sha256:584c80c24b078eec1e227079d56dc22ff755e0ba8654d8383b2c549107528918"}, - {file = "pytokens-0.4.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:da5baeaf7116dced9c6bb76dc31ba04a2dc3695f3d9f74741d7910122b456edc"}, - {file = "pytokens-0.4.1-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:11edda0942da80ff58c4408407616a310adecae1ddd22eef8c692fe266fa5009"}, - {file = "pytokens-0.4.1-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0fc71786e629cef478cbf29d7ea1923299181d0699dbe7c3c0f4a583811d9fc1"}, - {file = "pytokens-0.4.1-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:dcafc12c30dbaf1e2af0490978352e0c4041a7cde31f4f81435c2a5e8b9cabb6"}, - {file = "pytokens-0.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:42f144f3aafa5d92bad964d471a581651e28b24434d184871bd02e3a0d956037"}, - {file = "pytokens-0.4.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:34bcc734bd2f2d5fe3b34e7b3c0116bfb2397f2d9666139988e7a3eb5f7400e3"}, - {file = "pytokens-0.4.1-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:941d4343bf27b605e9213b26bfa1c4bf197c9c599a9627eb7305b0defcfe40c1"}, - {file = "pytokens-0.4.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3ad72b851e781478366288743198101e5eb34a414f1d5627cdd585ca3b25f1db"}, - {file = "pytokens-0.4.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:682fa37ff4d8e95f7df6fe6fe6a431e8ed8e788023c6bcc0f0880a12eab80ad1"}, - {file = "pytokens-0.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:30f51edd9bb7f85c748979384165601d028b84f7bd13fe14d3e065304093916a"}, - {file = "pytokens-0.4.1-py3-none-any.whl", hash = "sha256:26cef14744a8385f35d0e095dc8b3a7583f6c953c2e3d269c7f82484bf5ad2de"}, - {file = "pytokens-0.4.1.tar.gz", hash = "sha256:292052fe80923aae2260c073f822ceba21f3872ced9a68bb7953b348e561179a"}, -] - -[package.extras] -dev = ["black", "build", "mypy", "pytest", "pytest-cov", "setuptools", "tox", "twine", "wheel"] - [[package]] name = "pytz" version = "2026.1.post1" @@ -1568,4 +1458,4 @@ ruyaml = ">=0.91.0" [metadata] lock-version = "2.1" python-versions = "^3.9" -content-hash = "2b92bfa69dc376b562df12357dcc2ed09868a7282bc2848e62cb027324ba04bd" +content-hash = "e610d87eb797897e465595c13e0a3dcfe4dcc3e03e1386b8075df4195e9c1d86" diff --git a/pyproject.toml b/pyproject.toml index 89dee2c..33cd7c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,10 +29,7 @@ cwms-python = { version = ">=1.0.7", optional = true} colorama = "^0.4.6" [tool.poetry.group.dev.dependencies] -black = [ - { version = "^26.3.1", python = ">=3.10" }, - { version = "^24.2.0", python = ">=3.9,<3.10" }, -] +black = "==24.10.0" isort = "^5.13.2" mypy = "^1.9.0" pre-commit = "^3.6.2" diff --git a/tests/usgs/test_rating_ini_file_import.py b/tests/usgs/test_rating_ini_file_import.py index 5a913e3..15bd7c0 100644 --- a/tests/usgs/test_rating_ini_file_import.py +++ b/tests/usgs/test_rating_ini_file_import.py @@ -259,13 +259,15 @@ def test_import_with_real_file(self, mock_update, mock_init_cwms): def test_import_with_simple_ini_file(self): """Test import with a simple temporary INI file.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(""" + f.write( + """ # Test config cwms_office=MVP db_corr=$localid.Stage;Flow.USGS-CORR.USGS-NWIS localid=TESTLOC store_corr $($db_corr) -""") +""" + ) temp_file = f.name try: @@ -284,14 +286,16 @@ def test_import_with_simple_ini_file(self): def test_import_parameter_parsing(self): """Test that import correctly parses configuration parameters.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(r""" + f.write( + r""" cwms_office=MVP db_base=BASE_\$localid.SPEC db_exsa=EXSA_\$localid.SPEC db_corr=CORR_\$localid.SPEC localid=TESTLOC store_corr $($db_corr) -""") +""" + ) temp_file = f.name try: @@ -315,14 +319,16 @@ def test_import_parameter_parsing(self): def test_import_skips_comments(self): """Test that import correctly skips commented lines.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(""" + f.write( + """ cwms_office=MVP db_corr=$localid.Stage;Flow.USGS-CORR.USGS-NWIS db_exsa=$localid.Stage;Flow.USGS-EXSA.USGS-NWIS localid=LOC1 #store_corr $($db_corr) store_exsa $($db_exsa) -""") +""" + ) temp_file = f.name try: @@ -341,12 +347,14 @@ def test_import_skips_comments(self): def test_import_handles_inline_comments(self): """Test that import correctly handles inline comments.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(""" + f.write( + """ cwms_office=MVP # This is the office db_corr=$localid.Stage;Flow.USGS-CORR.USGS-NWIS localid=TESTLOC # Location identifier store_corr $($db_corr) -""") +""" + ) temp_file = f.name try: @@ -366,12 +374,14 @@ def test_import_handles_inline_comments(self): def test_import_office_id_uppercase(self): """Test that office_id is converted to uppercase.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(""" + f.write( + """ cwms_office=mvp db_corr=$localid.Stage;Flow.USGS-CORR.USGS-NWIS localid=TESTLOC store_corr $($db_corr) -""") +""" + ) temp_file = f.name try: @@ -391,14 +401,16 @@ def test_import_office_id_uppercase(self): def test_import_handles_multiple_locations(self): """Test that import correctly processes multiple location blocks.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(""" + f.write( + """ cwms_office=MVP db_corr=$localid.Stage;Flow.USGS-CORR.USGS-NWIS localid=LOC1 store_corr $($db_corr) localid=LOC2 store_corr $($db_corr) -""") +""" + ) temp_file = f.name try: @@ -417,12 +429,14 @@ def test_import_handles_multiple_locations(self): def test_import_localid_substitution(self): """Test that $localid is correctly substituted in specifications.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(r""" + f.write( + r""" cwms_office=MVP db_corr=\$localid.Stage;Flow.USGS-CORR.USGS-NWIS localid=MYLOC store_corr $($db_corr) -""") +""" + ) temp_file = f.name try: @@ -444,7 +458,8 @@ def test_import_localid_substitution(self): def test_import_cwmsid_substitution_with_nae_format(self): """Test NAE format with cwmsid and flexible db references (db_tail, db_river).""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(r""" + f.write( + r""" CWMS_OFFICE=NAE CWMS_DATABASE=local db_tail=\$cwmsid.Stage-TAILWATER;Flow.USGS-EXSA.USGS-NWIS @@ -459,7 +474,8 @@ def test_import_cwmsid_substitution_with_nae_format(self): usgsid=01151500 replace_exsa $(textfile) store_exsa $($db_river) -""") +""" + ) temp_file = f.name try: @@ -491,12 +507,14 @@ def test_import_cwmsid_substitution_with_nae_format(self): def test_dry_run_mode_calls_update_with_flag(self): """Test that dry_run mode calls update_rating_spec with dry_run=True.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(r""" + f.write( + r""" cwms_office=MVP db_corr=\$localid.Stage;Flow.USGS-CORR.USGS-NWIS localid=TESTLOC store_corr $($db_corr) -""") +""" + ) temp_file = f.name try: @@ -518,7 +536,8 @@ def test_dry_run_mode_calls_update_with_flag(self): def test_dry_run_mode_with_multiple_entries(self): """Test that dry_run processes all entries with dry_run flag.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(r""" + f.write( + r""" CWMS_OFFICE=NAE CWMS_DATABASE=local db_tail=\$cwmsid.Stage-TAILWATER;Flow.USGS-EXSA.USGS-NWIS @@ -535,7 +554,8 @@ def test_dry_run_mode_with_multiple_entries(self): cwmsid=NSD usgsid=01153000 store_exsa $($db_tail) -""") +""" + ) temp_file = f.name try: @@ -558,13 +578,15 @@ def test_dry_run_mode_with_multiple_entries(self): def test_import_custom_tag_substitution(self): """Test that custom tags (not just localid/cwmsid) are substituted.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(r""" + f.write( + r""" cwms_office=MVP db_corr=\$location.\$parameter.USGS-CORR.USGS-NWIS location=TESTLOC parameter=Stage;Flow store_corr $($db_corr) -""") +""" + ) temp_file = f.name try: @@ -589,12 +611,14 @@ def test_import_custom_tag_substitution(self): def test_normal_mode_calls_updates(self): """Test that normal mode (not dry_run) calls update_rating_spec with dry_run=False.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: - f.write(r""" + f.write( + r""" cwms_office=MVP db_corr=\$localid.Stage;Flow.USGS-CORR.USGS-NWIS localid=TESTLOC store_corr $($db_corr) -""") +""" + ) temp_file = f.name try: