diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d92cfc8da2..c89728df8a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -509,6 +509,90 @@ jobs: cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 nox-archive-hash: "${{ needs.prepare-workflow.outputs.nox-archive-hash }}" + almalinux-8-pkg-tests: + name: Alma Linux 8 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-8 + nox-session: ci-test-onedir + platform: linux + arch: x86_64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-8-arm64-pkg-tests: + name: Alma Linux 8 Arm64 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-8-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-9-pkg-tests: + name: Alma Linux 9 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-9 + nox-session: ci-test-onedir + platform: linux + arch: x86_64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-9-arm64-pkg-tests: + name: Alma Linux 9 Arm64 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-9-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + amazonlinux-2-pkg-tests: name: Amazon Linux 2 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -614,69 +698,6 @@ jobs: skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - centosstream-8-pkg-tests: - name: CentOS Stream 8 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-8 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - centosstream-9-pkg-tests: - name: CentOS Stream 9 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-9 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - centosstream-9-arm64-pkg-tests: - name: CentOS Stream 9 Arm64 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-9-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - debian-10-pkg-tests: name: Debian 10 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -782,48 +803,6 @@ jobs: skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - photonos-3-pkg-tests: - name: Photon OS 3 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: photonos-3 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - photonos-3-arm64-pkg-tests: - name: Photon OS 3 Arm64 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: photonos-3-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - photonos-4-pkg-tests: name: Photon OS 4 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1332,6 +1311,27 @@ jobs: workflow-slug: ci timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-8-arm64: + name: Alma Linux 8 Arm64 Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-ci-deps + uses: ./.github/workflows/test-action-linux.yml + with: + distro-slug: almalinux-8-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + nox-version: 2022.8.7 + gh-actions-python-version: "3.10" + testrun: ${{ needs.prepare-workflow.outputs.testrun }} + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} + workflow-slug: ci + timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-9: name: Alma Linux 9 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1353,6 +1353,27 @@ jobs: workflow-slug: ci timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-9-arm64: + name: Alma Linux 9 Arm64 Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-ci-deps + uses: ./.github/workflows/test-action-linux.yml + with: + distro-slug: almalinux-9-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + nox-version: 2022.8.7 + gh-actions-python-version: "3.10" + testrun: ${{ needs.prepare-workflow.outputs.testrun }} + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} + workflow-slug: ci + timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + amazonlinux-2: name: Amazon Linux 2 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1479,48 +1500,6 @@ jobs: workflow-slug: ci timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - centosstream-8: - name: CentOS Stream 8 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: centosstream-8 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} - workflow-slug: ci - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - centosstream-9: - name: CentOS Stream 9 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: centosstream-9 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} - workflow-slug: ci - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - debian-10: name: Debian 10 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1626,36 +1605,15 @@ jobs: workflow-slug: ci timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - fedora-37: - name: Fedora 37 Test + fedora-39: + name: Fedora 39 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} needs: - prepare-workflow - build-ci-deps uses: ./.github/workflows/test-action-linux.yml with: - distro-slug: fedora-37 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} - workflow-slug: ci - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - fedora-38: - name: Fedora 38 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: fedora-38 + distro-slug: fedora-39 nox-session: ci-test-onedir platform: linux arch: x86_64 @@ -1689,48 +1647,6 @@ jobs: workflow-slug: ci timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - photonos-3: - name: Photon OS 3 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: photonos-3 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} - workflow-slug: ci - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - photonos-3-arm64: - name: Photon OS 3 Arm64 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: photonos-3-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['skip_code_coverage'] }} - workflow-slug: ci - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - photonos-4: name: Photon OS 4 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1917,25 +1833,22 @@ jobs: - macos-13 - macos-13-xlarge - almalinux-8 + - almalinux-8-arm64 - almalinux-9 + - almalinux-9-arm64 - amazonlinux-2 - amazonlinux-2-arm64 - amazonlinux-2023 - amazonlinux-2023-arm64 - archlinux-lts - centos-7 - - centosstream-8 - - centosstream-9 - debian-10 - debian-11 - debian-11-arm64 - debian-12 - debian-12-arm64 - - fedora-37 - - fedora-38 + - fedora-39 - opensuse-15 - - photonos-3 - - photonos-3-arm64 - photonos-4 - photonos-4-arm64 - photonos-5 @@ -2074,25 +1987,22 @@ jobs: - macos-13 - macos-13-xlarge - almalinux-8 + - almalinux-8-arm64 - almalinux-9 + - almalinux-9-arm64 - amazonlinux-2 - amazonlinux-2-arm64 - amazonlinux-2023 - amazonlinux-2023-arm64 - archlinux-lts - centos-7 - - centosstream-8 - - centosstream-9 - debian-10 - debian-11 - debian-11-arm64 - debian-12 - debian-12-arm64 - - fedora-37 - - fedora-38 + - fedora-39 - opensuse-15 - - photonos-3 - - photonos-3-arm64 - photonos-4 - photonos-4-arm64 - photonos-5 @@ -2101,21 +2011,20 @@ jobs: - ubuntu-2004-arm64 - ubuntu-2204 - ubuntu-2204-arm64 + - almalinux-8-pkg-tests + - almalinux-8-arm64-pkg-tests + - almalinux-9-pkg-tests + - almalinux-9-arm64-pkg-tests - amazonlinux-2-pkg-tests - amazonlinux-2-arm64-pkg-tests - amazonlinux-2023-pkg-tests - amazonlinux-2023-arm64-pkg-tests - centos-7-pkg-tests - - centosstream-8-pkg-tests - - centosstream-9-pkg-tests - - centosstream-9-arm64-pkg-tests - debian-10-pkg-tests - debian-11-pkg-tests - debian-11-arm64-pkg-tests - debian-12-pkg-tests - debian-12-arm64-pkg-tests - - photonos-3-pkg-tests - - photonos-3-arm64-pkg-tests - photonos-4-pkg-tests - photonos-4-arm64-pkg-tests - photonos-5-pkg-tests diff --git a/.github/workflows/lint-action.yml b/.github/workflows/lint-action.yml index 6f177667129..9dc4be360e3 100644 --- a/.github/workflows/lint-action.yml +++ b/.github/workflows/lint-action.yml @@ -23,7 +23,7 @@ jobs: if: ${{ contains(fromJSON('["push", "schedule", "workflow_dispatch"]'), github.event_name) || fromJSON(inputs.changed-files)['salt'] || fromJSON(inputs.changed-files)['lint'] }} container: - image: ghcr.io/saltstack/salt-ci-containers/python:3.8 + image: ghcr.io/saltstack/salt-ci-containers/python:3.9 steps: - name: Install System Deps diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index a192568679a..3a7db8b4c2b 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -569,6 +569,90 @@ jobs: cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 nox-archive-hash: "${{ needs.prepare-workflow.outputs.nox-archive-hash }}" + almalinux-8-pkg-tests: + name: Alma Linux 8 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-8 + nox-session: ci-test-onedir + platform: linux + arch: x86_64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-8-arm64-pkg-tests: + name: Alma Linux 8 Arm64 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-8-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-9-pkg-tests: + name: Alma Linux 9 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-9 + nox-session: ci-test-onedir + platform: linux + arch: x86_64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-9-arm64-pkg-tests: + name: Alma Linux 9 Arm64 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-9-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + amazonlinux-2-pkg-tests: name: Amazon Linux 2 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -674,69 +758,6 @@ jobs: skip-code-coverage: false testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - centosstream-8-pkg-tests: - name: CentOS Stream 8 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-8 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - centosstream-9-pkg-tests: - name: CentOS Stream 9 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-9 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - centosstream-9-arm64-pkg-tests: - name: CentOS Stream 9 Arm64 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-9-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - debian-10-pkg-tests: name: Debian 10 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -842,48 +863,6 @@ jobs: skip-code-coverage: false testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - photonos-3-pkg-tests: - name: Photon OS 3 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: photonos-3 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - photonos-3-arm64-pkg-tests: - name: Photon OS 3 Arm64 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: photonos-3-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - photonos-4-pkg-tests: name: Photon OS 4 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1392,6 +1371,27 @@ jobs: workflow-slug: nightly timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-8-arm64: + name: Alma Linux 8 Arm64 Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-ci-deps + uses: ./.github/workflows/test-action-linux.yml + with: + distro-slug: almalinux-8-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + nox-version: 2022.8.7 + gh-actions-python-version: "3.10" + testrun: ${{ needs.prepare-workflow.outputs.testrun }} + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + workflow-slug: nightly + timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-9: name: Alma Linux 9 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1413,6 +1413,27 @@ jobs: workflow-slug: nightly timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-9-arm64: + name: Alma Linux 9 Arm64 Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-ci-deps + uses: ./.github/workflows/test-action-linux.yml + with: + distro-slug: almalinux-9-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + nox-version: 2022.8.7 + gh-actions-python-version: "3.10" + testrun: ${{ needs.prepare-workflow.outputs.testrun }} + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + workflow-slug: nightly + timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + amazonlinux-2: name: Amazon Linux 2 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1539,48 +1560,6 @@ jobs: workflow-slug: nightly timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - centosstream-8: - name: CentOS Stream 8 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: centosstream-8 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - workflow-slug: nightly - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - centosstream-9: - name: CentOS Stream 9 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: centosstream-9 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - workflow-slug: nightly - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - debian-10: name: Debian 10 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1686,36 +1665,15 @@ jobs: workflow-slug: nightly timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - fedora-37: - name: Fedora 37 Test + fedora-39: + name: Fedora 39 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} needs: - prepare-workflow - build-ci-deps uses: ./.github/workflows/test-action-linux.yml with: - distro-slug: fedora-37 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - workflow-slug: nightly - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - fedora-38: - name: Fedora 38 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: fedora-38 + distro-slug: fedora-39 nox-session: ci-test-onedir platform: linux arch: x86_64 @@ -1749,48 +1707,6 @@ jobs: workflow-slug: nightly timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - photonos-3: - name: Photon OS 3 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: photonos-3 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - workflow-slug: nightly - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - photonos-3-arm64: - name: Photon OS 3 Arm64 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: photonos-3-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - workflow-slug: nightly - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - photonos-4: name: Photon OS 4 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1977,25 +1893,22 @@ jobs: - macos-13 - macos-13-xlarge - almalinux-8 + - almalinux-8-arm64 - almalinux-9 + - almalinux-9-arm64 - amazonlinux-2 - amazonlinux-2-arm64 - amazonlinux-2023 - amazonlinux-2023-arm64 - archlinux-lts - centos-7 - - centosstream-8 - - centosstream-9 - debian-10 - debian-11 - debian-11-arm64 - debian-12 - debian-12-arm64 - - fedora-37 - - fedora-38 + - fedora-39 - opensuse-15 - - photonos-3 - - photonos-3-arm64 - photonos-4 - photonos-4-arm64 - photonos-5 @@ -2388,39 +2301,15 @@ jobs: arch: aarch64 - pkg-type: rpm distro: fedora - version: "37" + version: "39" arch: x86_64 - pkg-type: rpm distro: fedora - version: "37" + version: "39" arch: arm64 - pkg-type: rpm distro: fedora - version: "37" - arch: aarch64 - - pkg-type: rpm - distro: fedora - version: "38" - arch: x86_64 - - pkg-type: rpm - distro: fedora - version: "38" - arch: arm64 - - pkg-type: rpm - distro: fedora - version: "38" - arch: aarch64 - - pkg-type: rpm - distro: photon - version: "3" - arch: x86_64 - - pkg-type: rpm - distro: photon - version: "3" - arch: arm64 - - pkg-type: rpm - distro: photon - version: "3" + version: "39" arch: aarch64 - pkg-type: rpm distro: photon @@ -2902,25 +2791,22 @@ jobs: - macos-13 - macos-13-xlarge - almalinux-8 + - almalinux-8-arm64 - almalinux-9 + - almalinux-9-arm64 - amazonlinux-2 - amazonlinux-2-arm64 - amazonlinux-2023 - amazonlinux-2023-arm64 - archlinux-lts - centos-7 - - centosstream-8 - - centosstream-9 - debian-10 - debian-11 - debian-11-arm64 - debian-12 - debian-12-arm64 - - fedora-37 - - fedora-38 + - fedora-39 - opensuse-15 - - photonos-3 - - photonos-3-arm64 - photonos-4 - photonos-4-arm64 - photonos-5 @@ -2987,21 +2873,20 @@ jobs: - build-pkgs-src - combine-all-code-coverage - publish-repositories + - almalinux-8-pkg-tests + - almalinux-8-arm64-pkg-tests + - almalinux-9-pkg-tests + - almalinux-9-arm64-pkg-tests - amazonlinux-2-pkg-tests - amazonlinux-2-arm64-pkg-tests - amazonlinux-2023-pkg-tests - amazonlinux-2023-arm64-pkg-tests - centos-7-pkg-tests - - centosstream-8-pkg-tests - - centosstream-9-pkg-tests - - centosstream-9-arm64-pkg-tests - debian-10-pkg-tests - debian-11-pkg-tests - debian-11-arm64-pkg-tests - debian-12-pkg-tests - debian-12-arm64-pkg-tests - - photonos-3-pkg-tests - - photonos-3-arm64-pkg-tests - photonos-4-pkg-tests - photonos-4-arm64-pkg-tests - photonos-5-pkg-tests diff --git a/.github/workflows/release-update-winrepo.yml b/.github/workflows/release-update-winrepo.yml index 701c56d3cae..ab32d73d3c7 100644 --- a/.github/workflows/release-update-winrepo.yml +++ b/.github/workflows/release-update-winrepo.yml @@ -41,9 +41,12 @@ jobs: - name: Add Version to Minion Definition File working-directory: salt run: | + pwd + ls -al ../winrepo/salt-minion.sls python .github/workflows/scripts/update_winrepo.py \ --file ../winrepo/salt-minion.sls \ --version ${{ inputs.salt-version || github.ref_name }} + grep ${{ inputs.salt-version || github.ref_name }} ../winrepo/salt-minion.sls - name: Commit Changes working-directory: winrepo diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 177055929ea..0bd6ef698a2 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -551,6 +551,90 @@ jobs: cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 nox-archive-hash: "${{ needs.prepare-workflow.outputs.nox-archive-hash }}" + almalinux-8-pkg-tests: + name: Alma Linux 8 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-8 + nox-session: ci-test-onedir + platform: linux + arch: x86_64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-8-arm64-pkg-tests: + name: Alma Linux 8 Arm64 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-8-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-9-pkg-tests: + name: Alma Linux 9 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-9 + nox-session: ci-test-onedir + platform: linux + arch: x86_64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-9-arm64-pkg-tests: + name: Alma Linux 9 Arm64 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-9-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + amazonlinux-2-pkg-tests: name: Amazon Linux 2 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -656,69 +740,6 @@ jobs: skip-code-coverage: false testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - centosstream-8-pkg-tests: - name: CentOS Stream 8 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-8 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - centosstream-9-pkg-tests: - name: CentOS Stream 9 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-9 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - centosstream-9-arm64-pkg-tests: - name: CentOS Stream 9 Arm64 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-9-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - debian-10-pkg-tests: name: Debian 10 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -824,48 +845,6 @@ jobs: skip-code-coverage: false testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - photonos-3-pkg-tests: - name: Photon OS 3 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: photonos-3 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - photonos-3-arm64-pkg-tests: - name: Photon OS 3 Arm64 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: photonos-3-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - photonos-4-pkg-tests: name: Photon OS 4 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1374,6 +1353,27 @@ jobs: workflow-slug: scheduled timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-8-arm64: + name: Alma Linux 8 Arm64 Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-ci-deps + uses: ./.github/workflows/test-action-linux.yml + with: + distro-slug: almalinux-8-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + nox-version: 2022.8.7 + gh-actions-python-version: "3.10" + testrun: ${{ needs.prepare-workflow.outputs.testrun }} + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + workflow-slug: scheduled + timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-9: name: Alma Linux 9 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1395,6 +1395,27 @@ jobs: workflow-slug: scheduled timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-9-arm64: + name: Alma Linux 9 Arm64 Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-ci-deps + uses: ./.github/workflows/test-action-linux.yml + with: + distro-slug: almalinux-9-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + nox-version: 2022.8.7 + gh-actions-python-version: "3.10" + testrun: ${{ needs.prepare-workflow.outputs.testrun }} + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: false + workflow-slug: scheduled + timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + amazonlinux-2: name: Amazon Linux 2 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1521,48 +1542,6 @@ jobs: workflow-slug: scheduled timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - centosstream-8: - name: CentOS Stream 8 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: centosstream-8 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - workflow-slug: scheduled - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - centosstream-9: - name: CentOS Stream 9 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: centosstream-9 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - workflow-slug: scheduled - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - debian-10: name: Debian 10 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1668,36 +1647,15 @@ jobs: workflow-slug: scheduled timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - fedora-37: - name: Fedora 37 Test + fedora-39: + name: Fedora 39 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} needs: - prepare-workflow - build-ci-deps uses: ./.github/workflows/test-action-linux.yml with: - distro-slug: fedora-37 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - workflow-slug: scheduled - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - fedora-38: - name: Fedora 38 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: fedora-38 + distro-slug: fedora-39 nox-session: ci-test-onedir platform: linux arch: x86_64 @@ -1731,48 +1689,6 @@ jobs: workflow-slug: scheduled timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - photonos-3: - name: Photon OS 3 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: photonos-3 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - workflow-slug: scheduled - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - photonos-3-arm64: - name: Photon OS 3 Arm64 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: photonos-3-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: false - workflow-slug: scheduled - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - photonos-4: name: Photon OS 4 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1959,25 +1875,22 @@ jobs: - macos-13 - macos-13-xlarge - almalinux-8 + - almalinux-8-arm64 - almalinux-9 + - almalinux-9-arm64 - amazonlinux-2 - amazonlinux-2-arm64 - amazonlinux-2023 - amazonlinux-2023-arm64 - archlinux-lts - centos-7 - - centosstream-8 - - centosstream-9 - debian-10 - debian-11 - debian-11-arm64 - debian-12 - debian-12-arm64 - - fedora-37 - - fedora-38 + - fedora-39 - opensuse-15 - - photonos-3 - - photonos-3-arm64 - photonos-4 - photonos-4-arm64 - photonos-5 @@ -2118,25 +2031,22 @@ jobs: - macos-13 - macos-13-xlarge - almalinux-8 + - almalinux-8-arm64 - almalinux-9 + - almalinux-9-arm64 - amazonlinux-2 - amazonlinux-2-arm64 - amazonlinux-2023 - amazonlinux-2023-arm64 - archlinux-lts - centos-7 - - centosstream-8 - - centosstream-9 - debian-10 - debian-11 - debian-11-arm64 - debian-12 - debian-12-arm64 - - fedora-37 - - fedora-38 + - fedora-39 - opensuse-15 - - photonos-3 - - photonos-3-arm64 - photonos-4 - photonos-4-arm64 - photonos-5 @@ -2145,21 +2055,20 @@ jobs: - ubuntu-2004-arm64 - ubuntu-2204 - ubuntu-2204-arm64 + - almalinux-8-pkg-tests + - almalinux-8-arm64-pkg-tests + - almalinux-9-pkg-tests + - almalinux-9-arm64-pkg-tests - amazonlinux-2-pkg-tests - amazonlinux-2-arm64-pkg-tests - amazonlinux-2023-pkg-tests - amazonlinux-2023-arm64-pkg-tests - centos-7-pkg-tests - - centosstream-8-pkg-tests - - centosstream-9-pkg-tests - - centosstream-9-arm64-pkg-tests - debian-10-pkg-tests - debian-11-pkg-tests - debian-11-arm64-pkg-tests - debian-12-pkg-tests - debian-12-arm64-pkg-tests - - photonos-3-pkg-tests - - photonos-3-arm64-pkg-tests - photonos-4-pkg-tests - photonos-4-arm64-pkg-tests - photonos-5-pkg-tests diff --git a/.github/workflows/scripts/update_winrepo.py b/.github/workflows/scripts/update_winrepo.py index c0f2d00f417..ab2c92d44db 100644 --- a/.github/workflows/scripts/update_winrepo.py +++ b/.github/workflows/scripts/update_winrepo.py @@ -1,8 +1,10 @@ import argparse import os +print("Update winrepo script") + # Where are we -print(os.getcwd()) +print(f"Current working directory: {os.getcwd()}") arg_parser = argparse.ArgumentParser() arg_parser.add_argument("-f", "--file", help="the winrepo file to edit") @@ -12,10 +14,15 @@ args = arg_parser.parse_args() file = args.file version = args.version +print("Args:") +print(f"- file: {file}") +print(f"- version: {version}") + if version.startswith("v"): version = version[1:] with open(file) as f: + print(f"Opening file: {file}") current_contents = f.readlines() new_contents = [] @@ -24,8 +31,12 @@ added = False for line in current_contents: new_contents.append(line) if "load_yaml as versions_relenv" in line and not added: + print(f"Adding version: {version}") new_contents.append(f"- {version}\n") added = True with open(file, "w") as f: + print(f"Writing file: {file}") f.writelines(new_contents) + +print("Update winrepo script complete") diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 5bd828d5761..72096c06465 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -556,6 +556,90 @@ jobs: cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 nox-archive-hash: "${{ needs.prepare-workflow.outputs.nox-archive-hash }}" + almalinux-8-pkg-tests: + name: Alma Linux 8 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-8 + nox-session: ci-test-onedir + platform: linux + arch: x86_64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: true + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-8-arm64-pkg-tests: + name: Alma Linux 8 Arm64 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-8-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: true + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-9-pkg-tests: + name: Alma Linux 9 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-9 + nox-session: ci-test-onedir + platform: linux + arch: x86_64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: true + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + + almalinux-9-arm64-pkg-tests: + name: Alma Linux 9 Arm64 Package Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-pkgs-onedir + - build-ci-deps + uses: ./.github/workflows/test-packages-action-linux.yml + with: + distro-slug: almalinux-9-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + pkg-type: rpm + nox-version: 2022.8.7 + python-version: "3.10" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: true + testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} + amazonlinux-2-pkg-tests: name: Amazon Linux 2 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -661,69 +745,6 @@ jobs: skip-code-coverage: true testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - centosstream-8-pkg-tests: - name: CentOS Stream 8 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-8 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: true - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - centosstream-9-pkg-tests: - name: CentOS Stream 9 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-9 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: true - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - centosstream-9-arm64-pkg-tests: - name: CentOS Stream 9 Arm64 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: centosstream-9-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: true - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - debian-10-pkg-tests: name: Debian 10 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -829,48 +850,6 @@ jobs: skip-code-coverage: true testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - photonos-3-pkg-tests: - name: Photon OS 3 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: photonos-3 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: true - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - - photonos-3-arm64-pkg-tests: - name: Photon OS 3 Arm64 Package Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-pkgs-onedir - - build-ci-deps - uses: ./.github/workflows/test-packages-action-linux.yml - with: - distro-slug: photonos-3-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - pkg-type: rpm - nox-version: 2022.8.7 - python-version: "3.10" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: true - testing-releases: ${{ needs.prepare-workflow.outputs.testing-releases }} - photonos-4-pkg-tests: name: Photon OS 4 Package Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test-pkg'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1379,6 +1358,27 @@ jobs: workflow-slug: staging timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-8-arm64: + name: Alma Linux 8 Arm64 Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-ci-deps + uses: ./.github/workflows/test-action-linux.yml + with: + distro-slug: almalinux-8-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + nox-version: 2022.8.7 + gh-actions-python-version: "3.10" + testrun: ${{ needs.prepare-workflow.outputs.testrun }} + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: true + workflow-slug: staging + timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-9: name: Alma Linux 9 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1400,6 +1400,27 @@ jobs: workflow-slug: staging timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + almalinux-9-arm64: + name: Alma Linux 9 Arm64 Test + if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} + needs: + - prepare-workflow + - build-ci-deps + uses: ./.github/workflows/test-action-linux.yml + with: + distro-slug: almalinux-9-arm64 + nox-session: ci-test-onedir + platform: linux + arch: arm64 + nox-version: 2022.8.7 + gh-actions-python-version: "3.10" + testrun: ${{ needs.prepare-workflow.outputs.testrun }} + salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" + cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 + skip-code-coverage: true + workflow-slug: staging + timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} + amazonlinux-2: name: Amazon Linux 2 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1526,48 +1547,6 @@ jobs: workflow-slug: staging timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - centosstream-8: - name: CentOS Stream 8 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: centosstream-8 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: true - workflow-slug: staging - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - centosstream-9: - name: CentOS Stream 9 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: centosstream-9 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: true - workflow-slug: staging - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - debian-10: name: Debian 10 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -1673,36 +1652,15 @@ jobs: workflow-slug: staging timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - fedora-37: - name: Fedora 37 Test + fedora-39: + name: Fedora 39 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} needs: - prepare-workflow - build-ci-deps uses: ./.github/workflows/test-action-linux.yml with: - distro-slug: fedora-37 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: true - workflow-slug: staging - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - fedora-38: - name: Fedora 38 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: fedora-38 + distro-slug: fedora-39 nox-session: ci-test-onedir platform: linux arch: x86_64 @@ -1736,48 +1694,6 @@ jobs: workflow-slug: staging timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - photonos-3: - name: Photon OS 3 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: photonos-3 - nox-session: ci-test-onedir - platform: linux - arch: x86_64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: true - workflow-slug: staging - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - - photonos-3-arm64: - name: Photon OS 3 Arm64 Test - if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} - needs: - - prepare-workflow - - build-ci-deps - uses: ./.github/workflows/test-action-linux.yml - with: - distro-slug: photonos-3-arm64 - nox-session: ci-test-onedir - platform: linux - arch: arm64 - nox-version: 2022.8.7 - gh-actions-python-version: "3.10" - testrun: ${{ needs.prepare-workflow.outputs.testrun }} - salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}|3.10.13 - skip-code-coverage: true - workflow-slug: staging - timeout-minutes: ${{ fromJSON(needs.prepare-workflow.outputs.testrun)['type'] == 'full' && 180 || 360 }} - photonos-4: name: Photon OS 4 Test if: ${{ fromJSON(needs.prepare-workflow.outputs.jobs)['test'] && fromJSON(needs.prepare-workflow.outputs.runners)['self-hosted'] }} @@ -2227,39 +2143,15 @@ jobs: arch: aarch64 - pkg-type: rpm distro: fedora - version: "37" + version: "39" arch: x86_64 - pkg-type: rpm distro: fedora - version: "37" + version: "39" arch: arm64 - pkg-type: rpm distro: fedora - version: "37" - arch: aarch64 - - pkg-type: rpm - distro: fedora - version: "38" - arch: x86_64 - - pkg-type: rpm - distro: fedora - version: "38" - arch: arm64 - - pkg-type: rpm - distro: fedora - version: "38" - arch: aarch64 - - pkg-type: rpm - distro: photon - version: "3" - arch: x86_64 - - pkg-type: rpm - distro: photon - version: "3" - arch: arm64 - - pkg-type: rpm - distro: photon - version: "3" + version: "39" arch: aarch64 - pkg-type: rpm distro: photon @@ -2875,25 +2767,22 @@ jobs: - macos-13 - macos-13-xlarge - almalinux-8 + - almalinux-8-arm64 - almalinux-9 + - almalinux-9-arm64 - amazonlinux-2 - amazonlinux-2-arm64 - amazonlinux-2023 - amazonlinux-2023-arm64 - archlinux-lts - centos-7 - - centosstream-8 - - centosstream-9 - debian-10 - debian-11 - debian-11-arm64 - debian-12 - debian-12-arm64 - - fedora-37 - - fedora-38 + - fedora-39 - opensuse-15 - - photonos-3 - - photonos-3-arm64 - photonos-4 - photonos-4-arm64 - photonos-5 @@ -2902,21 +2791,20 @@ jobs: - ubuntu-2004-arm64 - ubuntu-2204 - ubuntu-2204-arm64 + - almalinux-8-pkg-tests + - almalinux-8-arm64-pkg-tests + - almalinux-9-pkg-tests + - almalinux-9-arm64-pkg-tests - amazonlinux-2-pkg-tests - amazonlinux-2-arm64-pkg-tests - amazonlinux-2023-pkg-tests - amazonlinux-2023-arm64-pkg-tests - centos-7-pkg-tests - - centosstream-8-pkg-tests - - centosstream-9-pkg-tests - - centosstream-9-arm64-pkg-tests - debian-10-pkg-tests - debian-11-pkg-tests - debian-11-arm64-pkg-tests - debian-12-pkg-tests - debian-12-arm64-pkg-tests - - photonos-3-pkg-tests - - photonos-3-arm64-pkg-tests - photonos-4-pkg-tests - photonos-4-arm64-pkg-tests - photonos-5-pkg-tests diff --git a/.github/workflows/test-package-downloads-action.yml b/.github/workflows/test-package-downloads-action.yml index ec1c2a83d23..93d43fc4b76 100644 --- a/.github/workflows/test-package-downloads-action.yml +++ b/.github/workflows/test-package-downloads-action.yml @@ -112,24 +112,6 @@ jobs: - distro-slug: centos-7-arm64 arch: arm64 pkg-type: package - - distro-slug: centosstream-8 - arch: x86_64 - pkg-type: package - - distro-slug: centosstream-8-arm64 - arch: aarch64 - pkg-type: package - - distro-slug: centosstream-8-arm64 - arch: arm64 - pkg-type: package - - distro-slug: centosstream-9 - arch: x86_64 - pkg-type: package - - distro-slug: centosstream-9-arm64 - arch: aarch64 - pkg-type: package - - distro-slug: centosstream-9-arm64 - arch: arm64 - pkg-type: package - distro-slug: debian-10 arch: x86_64 pkg-type: package @@ -148,31 +130,13 @@ jobs: - distro-slug: debian-12-arm64 arch: arm64 pkg-type: package - - distro-slug: fedora-37 + - distro-slug: fedora-39 arch: x86_64 pkg-type: package - - distro-slug: fedora-37-arm64 + - distro-slug: fedora-39-arm64 arch: aarch64 pkg-type: package - - distro-slug: fedora-37-arm64 - arch: arm64 - pkg-type: package - - distro-slug: fedora-38 - arch: x86_64 - pkg-type: package - - distro-slug: fedora-38-arm64 - arch: aarch64 - pkg-type: package - - distro-slug: fedora-38-arm64 - arch: arm64 - pkg-type: package - - distro-slug: photonos-3 - arch: x86_64 - pkg-type: package - - distro-slug: photonos-3-arm64 - arch: aarch64 - pkg-type: package - - distro-slug: photonos-3-arm64 + - distro-slug: fedora-39-arm64 arch: arm64 pkg-type: package - distro-slug: photonos-4 diff --git a/.gitignore b/.gitignore index acf579f4f67..5ec47806846 100644 --- a/.gitignore +++ b/.gitignore @@ -123,6 +123,7 @@ Session.vim # Nox requirements archives nox.*.tar.bzip2 +nox.*.tar.gz nox.*.tar.xz # Debian packages diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4eb7e3af7d8..316261fc059 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,7 +46,7 @@ repos: )$ - repo: https://github.com/saltstack/python-tools-scripts - rev: "0.18.6" + rev: "0.20.0" hooks: - id: tools alias: check-changelog-entries @@ -1166,6 +1166,7 @@ repos: # <---- Doc CI Requirements ---------------------------------------------------------------------------------------- # ----- Lint CI Requirements --------------------------------------------------------------------------------------> + - id: pip-tools-compile alias: compile-ci-lint-3.8-requirements name: Lint CI Py3.8 Requirements @@ -1467,7 +1468,12 @@ repos: hooks: - id: blacken-docs args: [--skip-errors] - files: ^doc/.*\.rst + files: ^(doc/)?.*\.(rst|md) + exclude: > + (?x)^( + rfcs/.*| + salt/ext/.*| + )$ additional_dependencies: - black==24.2.0 @@ -1519,7 +1525,7 @@ repos: - types-attrs - types-pyyaml - types-requests - - python-tools-scripts==0.18.6 + - python-tools-scripts==0.20.0 - repo: https://github.com/saltstack/mirrors-nox rev: v2022.11.21 diff --git a/.pylintrc b/.pylintrc index 1867165266b..5404f6522d0 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,25 +1,77 @@ -[MASTER] +[MAIN] + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Clear in-memory caches upon conclusion of linting. Useful if running pylint +# in a server-like mode. +clear-cache-post-run=no + +# Load and enable all available extensions. Use --list-extensions to see a list +# all available extensions. +#enable-all-extensions= + +# In error mode, messages with a category besides ERROR or FATAL are +# suppressed, and no reports are done by default. Error mode is compatible with +# disabling specific errors. +#errors-only= + +# Always return a 0 (non-error) status code, even if lint errors are found. +# This is primarily useful in continuous integration scripts. +#exit-zero= # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may # run arbitrary code. +extension-pkg-allow-list= + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. (This is an alternative name to extension-pkg-allow-list +# for backward compatibility.) extension-pkg-whitelist= -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS, - ext, +# Return non-zero exit code if any of these messages/categories are detected, +# even if score is above --fail-under value. Syntax same as enable. Messages +# specified are enabled, while categories only check already-enabled messages. +fail-on= -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns=salt.ext.* +# Specify a score threshold under which the program will exit with error. +fail-under=10 + +# Interpret the stdin as a python script, whose filename needs to be passed as +# the module_or_package argument. +#from-stdin= + +# Files or directories to be skipped. They should be base names, not paths. +ignore=CVS + +# Add files or directories matching the regular expressions patterns to the +# ignore-list. The regex matches against paths and can be in Posix or Windows +# format. Because '\\' represents the directory delimiter on Windows systems, +# it can't be used as an escape character. +ignore-paths= + +# Files or directories matching the regular expression patterns are skipped. +# The regex matches against base names, not paths. The default value ignores +# Emacs file locks +ignore-patterns=^\.# + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis). It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= # Python code to execute, usually for sys.path manipulation such as # pygtk.require(). #init-hook= # Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the -# number of processors available to use. +# number of processors available to use, and will cap the count on Windows to +# avoid hangs. jobs=1 # Control the amount of potential inferred values when inferring a single @@ -29,12 +81,8 @@ limit-inference-results=100 # List of plugins (as comma separated values of python module names) to load, # usually to register additional checkers. -load-plugins=saltpylint.pep8, - saltpylint.strings, - saltpylint.fileperms, - saltpylint.py3modernize, +load-plugins=saltpylint.fileperms, saltpylint.smartup, - saltpylint.minpyver, saltpylint.blacklist, saltpylint.thirdparty, saltpylint.dunder_del @@ -42,8 +90,18 @@ load-plugins=saltpylint.pep8, # Pickle collected data for later comparisons. persistent=no -# Specify a configuration file. -#rcfile= +# Minimum Python version to use for version dependent checks. Will default to +# the version used to run pylint. +py-version=3.9 + +# Discover python modules and packages in the file system subtree. +recursive=no + +# Add paths to the list of the source roots. Supports globbing patterns. The +# source root is an absolute path or a path relative to the current working +# directory used to determine a package namespace for modules located under the +# source root. +source-roots= # When enabled, pylint would attempt to guess common misconfiguration and emit # user-friendly hints instead of false-positive error messages. @@ -53,125 +111,215 @@ suggestion-mode=yes # active Python interpreter and may run arbitrary code. unsafe-load-any-extension=no -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once). You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use "--disable=all --enable=classes -# --disable=W". -disable=R, - locally-disabled, - file-ignored, - unexpected-special-method-signature, - import-error, - no-member, - unsubscriptable-object, - un-indexed-curly-braces-error, - whitespace-before-colon, - indentation-is-not-a-multiple-of-four-comment, - blacklisted-name, - invalid-name, - missing-docstring, - empty-docstring, - misplaced-comparison-constant, - unidiomatic-typecheck, - wrong-import-order, - ungrouped-imports, - wrong-import-position, - bad-mcs-method-argument, - bad-mcs-classmethod-argument, - line-too-long, - too-many-lines, - bad-continuation, - exec-used, - attribute-defined-outside-init, - protected-access, - reimported, - fixme, - global-statement, - unused-variable, - unused-argument, - redefined-outer-name, - redefined-builtin, - undefined-loop-variable, - logging-format-interpolation, - invalid-format-index, - line-too-long, - unexpected-indentation-comment, - continuation-line-indentation-is-not-a-multiple-of-four, - continuation-line-missing-indentation-or-outdented, - closing-bracket-does-not-match-indentation-of-opening-brackets-line, - closing-bracket-does-not-match-visual-indentation, - continuation-line-does-not-distinguish-itself-from-next-logical-line, - continuation-line-over-indented-for-hanging-indent, - continuation-line-over-indented-for-visual-indent, - continuation-line-under-indented-for-visual-indent, - visually-indented-line-with-same-indent-as-next-logical-line, - unaligned-for-hanging-indent, - block-comment-should-start-with-cardinal-space, - too-many-leading-hastag-for-block-comment, - module-level-import-not-at-top-of-file, - do-not-assign-a-lambda-expression-use-a-def, - 3rd-party-local-module-not-gated, - pep8-reserved-keywords, - import-outside-toplevel, - deprecated-method, - repr-flag-used-in-string, - keyword-arg-before-vararg, - incompatible-py3-code - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member, - literal-comparison +# In verbose mode, extra non-checker-related info will be displayed. +#verbose= -[REPORTS] +[BASIC] -# Python expression which should return a score less than or equal to 10. You -# have access to the variables 'error', 'warning', 'refactor', and 'convention' -# which contain the number of messages in each category, as well as 'statement' -# which is the total number of statements analyzed. This score is used by the -# global evaluation report (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) +# Naming style matching correct argument names. +argument-naming-style=snake_case -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details. -msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} +# Regular expression matching correct argument names. Overrides argument- +# naming-style. If left empty, argument names will be checked with the set +# naming style. +#argument-rgx= -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio). You can also give a reporter class, e.g. -# mypackage.mymodule.MyReporterClass. -output-format=parseable +# Naming style matching correct attribute names. +attr-naming-style=snake_case -# Tells whether to display a full report or only the messages. -reports=no +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. If left empty, attribute names will be checked with the set naming +# style. +#attr-rgx= -# Activate the evaluation score. -score=yes +# Bad variable names which should always be refused, separated by a comma. +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Bad variable names regexes, separated by a comma. If names match any regex, +# they will always be refused +bad-names-rgxs= + +# Naming style matching correct class attribute names. +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. If left empty, class attribute names will be checked +# with the set naming style. +#class-attribute-rgx= + +# Naming style matching correct class constant names. +class-const-naming-style=UPPER_CASE + +# Regular expression matching correct class constant names. Overrides class- +# const-naming-style. If left empty, class constant names will be checked with +# the set naming style. +#class-const-rgx= + +# Naming style matching correct class names. +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming- +# style. If left empty, class names will be checked with the set naming style. +#class-rgx= + +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style. If left empty, constant names will be checked with the set naming +# style. +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names. +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style. If left empty, function names will be checked with the set +# naming style. +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma. +good-names=exc, + Run, + _ + +# Good variable names regexes, separated by a comma. If names match any regex, +# they will always be accepted +good-names-rgxs= + +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=no + +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. If left empty, inline iteration names will be checked +# with the set naming style. +#inlinevar-rgx= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style. If left empty, method names will be checked with the set naming style. +#method-rgx= + +# Naming style matching correct module names. +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style. If left empty, module names will be checked with the set naming style. +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty + +# Regular expression matching correct type alias names. If left empty, type +# alias names will be checked with the set naming style. +#typealias-rgx= + +# Regular expression matching correct type variable names. If left empty, type +# variable names will be checked with the set naming style. +#typevar-rgx= + +# Naming style matching correct variable names. +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. If left empty, variable names will be checked with the set +# naming style. +#variable-rgx= -[REFACTORING] +[CLASSES] -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 +# Warn about protected attribute access inside special methods +check-protected-access-in-special-methods=no -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=sys.exit +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp, + asyncSetUp, + __post_init__ + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[DESIGN] + +# List of regular expressions of class ancestor names to ignore when counting +# public methods (see R0903) +exclude-too-few-public-methods= + +# List of qualified class names to ignore when counting class parents (see +# R0901) +ignored-parents= + +# Maximum number of arguments for function / method. +max-args=35 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in an if statement (see R0916). +max-bool-expr=5 + +# Maximum number of branch for function / method body. +max-branches=48 + +# Maximum number of locals for function / method body. +max-locals=40 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +# Maximum number of return / yield for function / method body. +max-returns=6 + +# Maximum number of statements in function / method body. +max-statements=100 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when caught. +overgeneral-exceptions=builtins.BaseException,builtins.Exception [FORMAT] @@ -195,13 +343,6 @@ max-line-length=120 # Maximum number of lines in a module. max-module-lines=3000 -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no @@ -211,141 +352,296 @@ single-line-class-stmt=no single-line-if-stmt=no +[IMPORTS] + +# List of modules that can be imported at any level, not just the top level +# one. +allow-any-import-level= + +# Allow explicit reexports by alias from a package __init__. +allow-reexport-from-package=no + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules= + +# Output a graph (.gv or any supported image format) of external dependencies +# to the given file (report RP0402 must not be disabled). +ext-import-graph= + +# Output a graph (.gv or any supported image format) of all (i.e. internal and +# external) dependencies to the given file (report RP0402 must not be +# disabled). +import-graph= + +# Output a graph (.gv or any supported image format) of internal dependencies +# to the given file (report RP0402 must not be disabled). +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + +# Couples of modules and preferred modules, separated by a comma. +preferred-modules= + + +[LOGGING] + +# The type of string formatting that logging methods do. `old` means using % +# formatting, `new` is for `{}` formatting. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, +# UNDEFINED. +confidence=HIGH, + CONTROL_FLOW, + INFERENCE, + INFERENCE_FAILURE, + UNDEFINED + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then re-enable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=R, + deprecated-pragma, + file-ignored, + locally-disabled, + suppressed-message, + use-implicit-booleaness-not-comparison-to-string, + use-implicit-booleaness-not-comparison-to-zero, + use-implicit-booleaness-not-comparison, + use-symbolic-message-instead, + useless-suppression, + 3rd-party-local-module-not-gated, + attribute-defined-outside-init, + bad-continuation, + bad-mcs-classmethod-argument, + bad-mcs-method-argument, + blacklisted-name, + deprecated-method, + empty-docstring, + exec-used, + file-ignored, + fixme, + global-statement, + import-error, + import-outside-toplevel, + invalid-format-index, + invalid-name, + keyword-arg-before-vararg, + line-too-long, + locally-disabled, + logging-format-interpolation, + missing-docstring, + no-member, + protected-access, + raw-checker-failed, + redefined-builtin, + redefined-outer-name, + reimported, + too-many-lines, + undefined-loop-variable, + unexpected-special-method-signature, + ungrouped-imports, + unidiomatic-typecheck, + unsubscriptable-object, + unused-argument, + unused-variable, + wrong-import-order, + wrong-import-position, + consider-using-f-string, + raise-missing-from, + broad-exception-raised, + consider-using-dict-items + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable= + + +[METHOD_ARGS] + +# List of qualified names (i.e., library.method) which require a timeout +# parameter e.g. 'requests.api.get,requests.api.post' +timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request + + [MISCELLANEOUS] # List of note tags to take in consideration, separated by a comma. notes=FIXME, - FIX, XXX, TODO +# Regular expression of note tags to take in consideration. +notes-rgx= -[BASIC] -# Naming style matching correct argument names. -argument-naming-style=snake_case +[REFACTORING] -# Regular expression matching correct argument names. Overrides argument- -# naming-style. -argument-rgx=[a-z_][a-z0-9_]{2,30}$ +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 -# Naming style matching correct attribute names. -attr-naming-style=snake_case +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit,argparse.parse_error -# Regular expression matching correct attribute names. Overrides attr-naming- -# style. -attr-rgx=[a-z_][a-z0-9_]{2,30}$ -# Bad variable names which should always be refused, separated by a comma. -bad-names=foo, - bar, - baz, - toto, - tutu, - tata +[REPORTS] -# Naming style matching correct class attribute names. -class-attribute-naming-style=any +# Python expression which should return a score less than or equal to 10. You +# have access to the variables 'fatal', 'error', 'warning', 'refactor', +# 'convention', and 'info' which contain the number of messages in each +# category, as well as 'statement' which is the total number of statements +# analyzed. This score is used by the global evaluation report (RP0004). +evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)) -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style. -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +msg-template= -# Naming style matching correct class names. -class-naming-style=PascalCase +# Set the output format. Available formats are: text, parseable, colorized, +# json2 (improved json format), json (old json format) and msvs (visual +# studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +output-format=parseable -# Regular expression matching correct class names. Overrides class-naming- -# style. -class-rgx=[A-Z_][a-zA-Z0-9]+$ +# Tells whether to display a full report or only the messages. +reports=no -# Naming style matching correct constant names. -const-naming-style=UPPER_CASE +# Activate the evaluation score. +score=yes -# Regular expression matching correct constant names. Overrides const-naming- -# style. -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 +[SIMILARITIES] -# Naming style matching correct function names. -function-naming-style=snake_case +# Comments are removed from the similarity computation +ignore-comments=yes -# Regular expression matching correct function names. Overrides function- -# naming-style. -function-rgx=[a-z_][a-z0-9_]{2,30}$ +# Docstrings are removed from the similarity computation +ignore-docstrings=yes -# Good variable names which should always be accepted, separated by a comma. -good-names=i, - j, - k, - ex, - Run, - _, - log +# Imports are removed from the similarity computation +ignore-imports=yes -# Include a hint for the correct naming format with invalid-name. -include-naming-hint=yes +# Signatures are removed from the similarity computation +ignore-signatures=yes -# Naming style matching correct inline iteration names. -inlinevar-naming-style=any +# Minimum lines number of a similarity. +min-similarity-lines=4 -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style. -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ -# Naming style matching correct method names. -method-naming-style=snake_case +[SPELLING] -# Regular expression matching correct method names. Overrides method-naming- -# style. -method-rgx=[a-z_][a-z0-9_]{2,30}$ +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 -# Naming style matching correct module names. -module-naming-style=snake_case +# Spelling dictionary name. No available dictionaries : You need to install +# both the python package and the system dependency for enchant to work. +spelling-dict= -# Regular expression matching correct module names. Overrides module-naming- -# style. -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ +# List of comma separated words that should be considered directives if they +# appear at the beginning of a comment and should not be checked. +spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy: -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= +# List of comma separated words that should not be checked. +spelling-ignore-words= -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=__.*__ +# A path to a file that contains the private dictionary; one word per line. +spelling-private-dict-file= -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -# These decorators are taken in consideration only for invalid-name. -property-classes=abc.abstractproperty - -# Naming style matching correct variable names. -variable-naming-style=snake_case - -# Regular expression matching correct variable names. Overrides variable- -# naming-style. -variable-rgx=[a-z_][a-z0-9_]{2,30}$ +# Tells whether to store unknown words to the private dictionary (see the +# --spelling-private-dict-file option) instead of raising a message. +spelling-store-unknown-words=no [STRING] -# This flag controls whether the implicit-str-concat-in-sequence should -# generate a warning on implicit string concatenation in sequences defined over -# several lines. +# This flag controls whether inconsistent-quotes generates a warning when the +# character used as a quote delimiter is used inconsistently within a module. +check-quote-consistency=no + +# This flag controls whether the implicit-str-concat should generate a warning +# on implicit string concatenation in sequences defined over several lines. check-str-concat-over-line-jumps=no -# Enforce string formatting over string substitution -enforce-string-formatting-over-substitution=yes -# Force string substitution usage on strings to always be an error. -string-substitutions-usage-is-an-error=yes +[TYPECHECK] -# Force un-indexed curly braces on a 'string.format()' call to always be an -# error. -un-indexed-curly-braces-always-error=no +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of symbolic message names to ignore for Mixin members. +ignored-checks-for-mixins=no-member, + not-async-context-manager, + not-context-manager, + attribute-defined-outside-init + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + +# Regex pattern to define which classes are considered mixins. +mixin-class-rgx=.*[Mm]ixin + +# List of decorators that change the signature of a decorated function. +signature-mutators= [VARIABLES] @@ -379,6 +675,9 @@ additional-builtins=__opts__, # Tells whether unused global variables should be treated as a violation. allow-global-unused-variables=yes +# List of names allowed to shadow builtins +allowed-redefined-builtins= + # List of strings which can identify a callback function by name. A callback # name must start or end with one of those strings. callbacks=cb_, @@ -386,128 +685,17 @@ callbacks=cb_, # A regular expression matching the name of dummy variables (i.e. expected to # not be used). -dummy-variables-rgx=_|dummy +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ -# Argument names that match this expression will be ignored. Default to name -# with leading underscore. -ignored-argument-names=_.* +# Argument names that match this expression will be ignored. +ignored-argument-names=_.*|^ignored_|^unused_ # Tells whether we should check for unused import in __init__ files. init-import=no # List of qualified module names which can have objects that can redefine # builtins. -redefining-builtins-modules=six.moves, - salt.ext.six.moves, - past.builtins, - future.builtins, - builtins, - io - - -[LOGGING] - -# Format style used to check logging format string. `old` means using % -# formatting, `new` is for `{}` formatting,and `fstr` is for f-strings. -logging-format-style=old - -# Logging modules to check that the string format arguments are in logging -# function parameter format. -logging-modules= - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes. -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it work, -# install the python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains the private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to the private dictionary (see the -# --spelling-private-dict-file option) instead of raising a message. -spelling-store-unknown-words=no - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members=REQUEST, - acl_users, - aq_parent - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# Tells whether to warn about missing members when the owner of the attribute -# is inferred to be None. -ignore-none=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=SQLObject - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis). It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules=salt.ext.six.moves, - six.moves, - _MovedItems, - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - -# List of decorators that change the signature of a decorated function. -signature-mutators= - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io [FILEPERMS] @@ -518,135 +706,6 @@ fileperms-default=0644 # File paths to ignore file permission. Glob patterns allowed. fileperms-ignore-paths=setup.py,noxfile.py,tests/runtests.py,tests/saltsh.py,tests/buildpackage.py,tests/unit/files/rosters/ansible/roster.py - -[MODERNIZE] - -# Fix up doctests only -modernize-doctests-only=no - -# Each FIX specifies a transformation; "default" includes default fixes. -modernize-fix= - -# Use 'from __future__ import unicode_literals' (only useful for Python 2.6+). -modernize-future-unicode=no - -# Exclude fixes that depend on the six package. -modernize-no-six=no - -# Comma separated list of fixer names not to fix. -modernize-nofix= - -# Modify the grammar so that print() is a function. -modernize-print-function=yes - -# Wrap unicode literals in six.u(). -modernize-six-unicode=no - - -[MININUM-PYTHON-VERSION] - -# The desired minimum python version to enforce. Default: 2.6 -minimum-python-version=2.7 - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[DESIGN] - -# Maximum number of arguments for function / method. -max-args=35 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in an if statement (see R0916). -max-bool-expr=5 - -# Maximum number of branch for function / method body. -max-branches=48 - -# Maximum number of locals for function / method body. -max-locals=40 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body. -max-returns=6 - -# Maximum number of statements in function / method body. -max-statements=100 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[IMPORTS] - -# List of modules that can be imported at any level, not just the top level -# one. -allow-any-import-level= - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=yes - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=yes - -# Deprecated modules which should not be used, separated by a comma. -deprecated-modules=regsub, - TERMIOS, - Bastion, - rexec - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled). -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled). -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled). -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - -# Couples of modules and preferred modules, separated by a comma. -preferred-modules= - - [BLACKLISTED-FUNCTIONS] # List of blacklisted functions and suggested replacements @@ -702,10 +761,3 @@ allowed-3rd-party-modules=msgpack, cryptography, aiohttp, pytest_timeout - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "BaseException, Exception". -overgeneral-exceptions=BaseException, - Exception diff --git a/changelog/65859.added.md b/changelog/65859.added.md new file mode 100644 index 00000000000..533278e73b4 --- /dev/null +++ b/changelog/65859.added.md @@ -0,0 +1 @@ +Add Fedora 39 support diff --git a/changelog/65860.deprecated.md b/changelog/65860.deprecated.md new file mode 100644 index 00000000000..ca1ae532af1 --- /dev/null +++ b/changelog/65860.deprecated.md @@ -0,0 +1 @@ +Drop Fedora 37 and Fedora 38 support diff --git a/changelog/66104.deprecated.md b/changelog/66104.deprecated.md new file mode 100644 index 00000000000..0d0993fa120 --- /dev/null +++ b/changelog/66104.deprecated.md @@ -0,0 +1 @@ +Drop CentOS Stream 8 and 9 from CI/CD diff --git a/changelog/66105.deprecated.md b/changelog/66105.deprecated.md new file mode 100644 index 00000000000..f3bc682f0af --- /dev/null +++ b/changelog/66105.deprecated.md @@ -0,0 +1 @@ +Drop Photon OS 3 support diff --git a/changelog/66126.fixed.md b/changelog/66126.fixed.md new file mode 100644 index 00000000000..9879189e644 --- /dev/null +++ b/changelog/66126.fixed.md @@ -0,0 +1,2 @@ +Fixed a issue with server channel where a minion's public key +would be rejected if it contained a final newline character. diff --git a/changelog/66139.deprecated.md b/changelog/66139.deprecated.md new file mode 100644 index 00000000000..aa7f4cf64f9 --- /dev/null +++ b/changelog/66139.deprecated.md @@ -0,0 +1 @@ +The ``salt.utils.psutil_compat`` module has been deprecated and will be removed in Salt 3008. Please use the ``psutil`` module directly. diff --git a/changelog/66141.security.md b/changelog/66141.security.md new file mode 100644 index 00000000000..b5ef0f14974 --- /dev/null +++ b/changelog/66141.security.md @@ -0,0 +1,5 @@ +Upgrade to `cryptography==42.0.5` due to a few security issues: + +* https://github.com/advisories/GHSA-9v9h-cgj8-h64p +* https://github.com/advisories/GHSA-3ww4-gg4f-jr7f +* https://github.com/advisories/GHSA-6vqw-3v5j-54x4 diff --git a/cicd/amis.yml b/cicd/amis.yml deleted file mode 100644 index bebd8141fbb..00000000000 --- a/cicd/amis.yml +++ /dev/null @@ -1 +0,0 @@ -centosstream-9-x86_64: ami-0793e1741f291eaf9 diff --git a/cicd/golden-images.json b/cicd/golden-images.json index e886e13ed82..7c6e621bc9f 100644 --- a/cicd/golden-images.json +++ b/cicd/golden-images.json @@ -1,8 +1,8 @@ { "almalinux-8-arm64": { - "ami": "ami-0a2b327b74836f618", + "ami": "ami-045a65c1d4ceb04a5", "ami_description": "CI Image of AlmaLinux 8 arm64", - "ami_name": "salt-project/ci/almalinux/8/arm64/20231126.1417", + "ami_name": "salt-project/ci/almalinux/8/arm64/20240209.1843", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", @@ -10,9 +10,9 @@ "ssh_username": "ec2-user" }, "almalinux-8": { - "ami": "ami-03d4319831692a030", + "ami": "ami-0b9c2b7ba679e691d", "ami_description": "CI Image of AlmaLinux 8 x86_64", - "ami_name": "salt-project/ci/almalinux/8/x86_64/20231126.1417", + "ami_name": "salt-project/ci/almalinux/8/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -20,9 +20,9 @@ "ssh_username": "ec2-user" }, "almalinux-9-arm64": { - "ami": "ami-01e0f60c59c6fe8f3", + "ami": "ami-0cbdf762adc955d47", "ami_description": "CI Image of AlmaLinux 9 arm64", - "ami_name": "salt-project/ci/almalinux/9/arm64/20231126.1417", + "ami_name": "salt-project/ci/almalinux/9/arm64/20240209.1844", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", @@ -30,9 +30,9 @@ "ssh_username": "ec2-user" }, "almalinux-9": { - "ami": "ami-0dbbac81b50ebb8b4", + "ami": "ami-086c8ef0ef6951a8f", "ami_description": "CI Image of AlmaLinux 9 x86_64", - "ami_name": "salt-project/ci/almalinux/9/x86_64/20231126.1417", + "ami_name": "salt-project/ci/almalinux/9/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -40,9 +40,9 @@ "ssh_username": "ec2-user" }, "amazonlinux-2-arm64": { - "ami": "ami-05cc59dcbf59085f1", + "ami": "ami-07bc422e281c67f10", "ami_description": "CI Image of AmazonLinux 2 arm64", - "ami_name": "salt-project/ci/amazonlinux/2/arm64/20231126.1417", + "ami_name": "salt-project/ci/amazonlinux/2/arm64/20240209.1843", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", @@ -50,9 +50,9 @@ "ssh_username": "ec2-user" }, "amazonlinux-2": { - "ami": "ami-07f715092c8ed2451", + "ami": "ami-01ecdeb9a8251824e", "ami_description": "CI Image of AmazonLinux 2 x86_64", - "ami_name": "salt-project/ci/amazonlinux/2/x86_64/20231126.1417", + "ami_name": "salt-project/ci/amazonlinux/2/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -60,9 +60,9 @@ "ssh_username": "ec2-user" }, "amazonlinux-2023-arm64": { - "ami": "ami-074502af4314eb812", + "ami": "ami-0b8a0efa9ea7ebfa4", "ami_description": "CI Image of AmazonLinux 2023 arm64", - "ami_name": "salt-project/ci/amazonlinux/2023/arm64/20231126.1417", + "ami_name": "salt-project/ci/amazonlinux/2023/arm64/20240209.1844", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", @@ -70,9 +70,9 @@ "ssh_username": "ec2-user" }, "amazonlinux-2023": { - "ami": "ami-0a1059334d3373321", + "ami": "ami-0f013d0d9dbaf3b06", "ami_description": "CI Image of AmazonLinux 2023 x86_64", - "ami_name": "salt-project/ci/amazonlinux/2023/x86_64/20231126.1417", + "ami_name": "salt-project/ci/amazonlinux/2023/x86_64/20240209.1844", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -80,9 +80,9 @@ "ssh_username": "ec2-user" }, "archlinux-lts": { - "ami": "ami-0430452d2dfbb8f4b", + "ami": "ami-01f729941d3262787", "ami_description": "CI Image of ArchLinux lts x86_64", - "ami_name": "salt-project/ci/archlinux/lts/x86_64/20231126.1417", + "ami_name": "salt-project/ci/archlinux/lts/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "false", "instance_type": "t3a.large", @@ -90,9 +90,9 @@ "ssh_username": "arch" }, "centos-7-arm64": { - "ami": "ami-0fc26a930a59d1417", + "ami": "ami-09c1e87fa7a2be337", "ami_description": "CI Image of CentOS 7 arm64", - "ami_name": "salt-project/ci/centos/7/arm64/20231126.1417", + "ami_name": "salt-project/ci/centos/7/arm64/20240209.1843", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", @@ -100,59 +100,19 @@ "ssh_username": "centos" }, "centos-7": { - "ami": "ami-0532c2c5f18771fa8", + "ami": "ami-010faf67fdabfbcdf", "ami_description": "CI Image of CentOS 7 x86_64", - "ami_name": "salt-project/ci/centos/7/x86_64/20231126.1417", + "ami_name": "salt-project/ci/centos/7/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", "is_windows": "false", "ssh_username": "centos" }, - "centosstream-8-arm64": { - "ami": "ami-0916df690c02e0af0", - "ami_description": "CI Image of CentOSStream 8 arm64", - "ami_name": "salt-project/ci/centosstream/8/arm64/20231126.1417", - "arch": "arm64", - "cloudwatch-agent-available": "true", - "instance_type": "m6g.large", - "is_windows": "false", - "ssh_username": "centos" - }, - "centosstream-8": { - "ami": "ami-06cf36f0232c681e2", - "ami_description": "CI Image of CentOSStream 8 x86_64", - "ami_name": "salt-project/ci/centosstream/8/x86_64/20231126.1416", - "arch": "x86_64", - "cloudwatch-agent-available": "true", - "instance_type": "t3a.large", - "is_windows": "false", - "ssh_username": "centos" - }, - "centosstream-9-arm64": { - "ami": "ami-094e17e254aa77811", - "ami_description": "CI Image of CentOSStream 9 arm64", - "ami_name": "salt-project/ci/centosstream/9/arm64/20231126.1417", - "arch": "arm64", - "cloudwatch-agent-available": "true", - "instance_type": "m6g.large", - "is_windows": "false", - "ssh_username": "ec2-user" - }, - "centosstream-9": { - "ami": "ami-0793e1741f291eaf9", - "ami_description": "CI Image of CentOSStream 9 x86_64", - "ami_name": "salt-project/ci/centosstream/9/x86_64/20231126.1417", - "arch": "x86_64", - "cloudwatch-agent-available": "true", - "instance_type": "t3a.large", - "is_windows": "false", - "ssh_username": "ec2-user" - }, "debian-10-arm64": { - "ami": "ami-0c0b1bdab1b3c9733", + "ami": "ami-018ff5d81815e307f", "ami_description": "CI Image of Debian 10 arm64", - "ami_name": "salt-project/ci/debian/10/arm64/20231126.1417", + "ami_name": "salt-project/ci/debian/10/arm64/20240209.1843", "arch": "arm64", "cloudwatch-agent-available": "false", "instance_type": "m6g.large", @@ -160,9 +120,9 @@ "ssh_username": "admin" }, "debian-10": { - "ami": "ami-082605fda5afd9131", + "ami": "ami-033f768666c97d386", "ami_description": "CI Image of Debian 10 x86_64", - "ami_name": "salt-project/ci/debian/10/x86_64/20231126.1417", + "ami_name": "salt-project/ci/debian/10/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -170,9 +130,9 @@ "ssh_username": "admin" }, "debian-11-arm64": { - "ami": "ami-0df6946d840d24ced", + "ami": "ami-02dfec8b374ad8fc8", "ami_description": "CI Image of Debian 11 arm64", - "ami_name": "salt-project/ci/debian/11/arm64/20231126.1417", + "ami_name": "salt-project/ci/debian/11/arm64/20240209.1843", "arch": "arm64", "cloudwatch-agent-available": "false", "instance_type": "m6g.large", @@ -180,9 +140,9 @@ "ssh_username": "admin" }, "debian-11": { - "ami": "ami-0c2198080c953861d", + "ami": "ami-06e4f77ed230e2def", "ami_description": "CI Image of Debian 11 x86_64", - "ami_name": "salt-project/ci/debian/11/x86_64/20231126.1417", + "ami_name": "salt-project/ci/debian/11/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -190,9 +150,9 @@ "ssh_username": "admin" }, "debian-12-arm64": { - "ami": "ami-050b69eb0e0a66373", + "ami": "ami-05c7771a9ec62dfb2", "ami_description": "CI Image of Debian 12 arm64", - "ami_name": "salt-project/ci/debian/12/arm64/20231126.1417", + "ami_name": "salt-project/ci/debian/12/arm64/20240209.1843", "arch": "arm64", "cloudwatch-agent-available": "false", "instance_type": "m6g.large", @@ -200,49 +160,29 @@ "ssh_username": "admin" }, "debian-12": { - "ami": "ami-032e397b97865f83e", + "ami": "ami-0ac4b96d4ae5faa23", "ami_description": "CI Image of Debian 12 x86_64", - "ami_name": "salt-project/ci/debian/12/x86_64/20231126.1417", + "ami_name": "salt-project/ci/debian/12/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", "is_windows": "false", "ssh_username": "admin" }, - "fedora-37-arm64": { - "ami": "ami-0000739b5d4971ba1", - "ami_description": "CI Image of Fedora 37 arm64", - "ami_name": "salt-project/ci/fedora/37/arm64/20231126.1417", + "fedora-39-arm64": { + "ami": "ami-04f69299edce3ff91", + "ami_description": "CI Image of Fedora 39 arm64", + "ami_name": "salt-project/ci/fedora/39/arm64/20240209.1844", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", "is_windows": "false", "ssh_username": "fedora" }, - "fedora-37": { - "ami": "ami-086af8fe37696acd6", - "ami_description": "CI Image of Fedora 37 x86_64", - "ami_name": "salt-project/ci/fedora/37/x86_64/20231126.1417", - "arch": "x86_64", - "cloudwatch-agent-available": "true", - "instance_type": "t3a.large", - "is_windows": "false", - "ssh_username": "fedora" - }, - "fedora-38-arm64": { - "ami": "ami-0a078cdd3a57ef342", - "ami_description": "CI Image of Fedora 38 arm64", - "ami_name": "salt-project/ci/fedora/38/arm64/20231126.1417", - "arch": "arm64", - "cloudwatch-agent-available": "true", - "instance_type": "m6g.large", - "is_windows": "false", - "ssh_username": "fedora" - }, - "fedora-38": { - "ami": "ami-0566e7f93c5cf6afc", - "ami_description": "CI Image of Fedora 38 x86_64", - "ami_name": "salt-project/ci/fedora/38/x86_64/20231126.1417", + "fedora-39": { + "ami": "ami-033bf14cad5d795a2", + "ami_description": "CI Image of Fedora 39 x86_64", + "ami_name": "salt-project/ci/fedora/39/x86_64/20240209.1844", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -250,39 +190,19 @@ "ssh_username": "fedora" }, "opensuse-15": { - "ami": "ami-0c64c574d488d33f6", + "ami": "ami-023efb1898809e8fe", "ami_description": "CI Image of Opensuse 15 x86_64", - "ami_name": "salt-project/ci/opensuse/15/x86_64/20231126.1417", + "ami_name": "salt-project/ci/opensuse/15/x86_64/20240209.1844", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", "is_windows": "false", "ssh_username": "ec2-user" }, - "photonos-3-arm64": { - "ami": "ami-03ac724168ce02eed", - "ami_description": "CI Image of PhotonOS 3 arm64", - "ami_name": "salt-project/ci/photonos/3/arm64/20231126.1417", - "arch": "arm64", - "cloudwatch-agent-available": "true", - "instance_type": "m6g.large", - "is_windows": "false", - "ssh_username": "root" - }, - "photonos-3": { - "ami": "ami-0072dfd1f7bc5f586", - "ami_description": "CI Image of PhotonOS 3 x86_64", - "ami_name": "salt-project/ci/photonos/3/x86_64/20231126.1417", - "arch": "x86_64", - "cloudwatch-agent-available": "true", - "instance_type": "t3a.large", - "is_windows": "false", - "ssh_username": "root" - }, "photonos-4-arm64": { - "ami": "ami-05a215fe4cf29227b", + "ami": "ami-0d164263b5095dc45", "ami_description": "CI Image of PhotonOS 4 arm64", - "ami_name": "salt-project/ci/photonos/4/arm64/20231126.1417", + "ami_name": "salt-project/ci/photonos/4/arm64/20240209.1844", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", @@ -290,9 +210,9 @@ "ssh_username": "root" }, "photonos-4": { - "ami": "ami-06addda42fc8c5db3", + "ami": "ami-0454d6f4e80b94412", "ami_description": "CI Image of PhotonOS 4 x86_64", - "ami_name": "salt-project/ci/photonos/4/x86_64/20231126.1417", + "ami_name": "salt-project/ci/photonos/4/x86_64/20240209.1844", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -300,9 +220,9 @@ "ssh_username": "root" }, "photonos-5-arm64": { - "ami": "ami-0e78012df225dbe96", + "ami": "ami-094f4c1e098fc2192", "ami_description": "CI Image of PhotonOS 5 arm64", - "ami_name": "salt-project/ci/photonos/5/arm64/20231126.1417", + "ami_name": "salt-project/ci/photonos/5/arm64/20240209.1844", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", @@ -310,9 +230,9 @@ "ssh_username": "root" }, "photonos-5": { - "ami": "ami-0fc61f964bc262714", + "ami": "ami-037344b8f3d9e2650", "ami_description": "CI Image of PhotonOS 5 x86_64", - "ami_name": "salt-project/ci/photonos/5/x86_64/20231126.1417", + "ami_name": "salt-project/ci/photonos/5/x86_64/20240209.1844", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -320,9 +240,9 @@ "ssh_username": "root" }, "ubuntu-20.04-arm64": { - "ami": "ami-0cc504307b587cd77", + "ami": "ami-0eb0f403664076b82", "ami_description": "CI Image of Ubuntu 20.04 arm64", - "ami_name": "salt-project/ci/ubuntu/20.04/arm64/20231126.1417", + "ami_name": "salt-project/ci/ubuntu/20.04/arm64/20240209.1843", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", @@ -330,9 +250,9 @@ "ssh_username": "ubuntu" }, "ubuntu-20.04": { - "ami": "ami-03376fca39f6d9186", + "ami": "ami-07ad57960d22a8b65", "ami_description": "CI Image of Ubuntu 20.04 x86_64", - "ami_name": "salt-project/ci/ubuntu/20.04/x86_64/20231126.1417", + "ami_name": "salt-project/ci/ubuntu/20.04/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -340,9 +260,9 @@ "ssh_username": "ubuntu" }, "ubuntu-22.04-arm64": { - "ami": "ami-0be361d529bb46410", + "ami": "ami-05197331792cbc895", "ami_description": "CI Image of Ubuntu 22.04 arm64", - "ami_name": "salt-project/ci/ubuntu/22.04/arm64/20231126.1417", + "ami_name": "salt-project/ci/ubuntu/22.04/arm64/20240209.1843", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", @@ -350,9 +270,9 @@ "ssh_username": "ubuntu" }, "ubuntu-22.04": { - "ami": "ami-0c9d29f29868da4ce", + "ami": "ami-01d9f296a69eaec3c", "ami_description": "CI Image of Ubuntu 22.04 x86_64", - "ami_name": "salt-project/ci/ubuntu/22.04/x86_64/20231126.1417", + "ami_name": "salt-project/ci/ubuntu/22.04/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -360,9 +280,9 @@ "ssh_username": "ubuntu" }, "ubuntu-23.04-arm64": { - "ami": "ami-0b80ab7ead3c7d289", + "ami": "ami-0511f6146f198b645", "ami_description": "CI Image of Ubuntu 23.04 arm64", - "ami_name": "salt-project/ci/ubuntu/23.04/arm64/20231126.1417", + "ami_name": "salt-project/ci/ubuntu/23.04/arm64/20240209.1843", "arch": "arm64", "cloudwatch-agent-available": "true", "instance_type": "m6g.large", @@ -370,9 +290,9 @@ "ssh_username": "ubuntu" }, "ubuntu-23.04": { - "ami": "ami-0d17dce1842e37811", + "ami": "ami-0f09467d281f1a312", "ami_description": "CI Image of Ubuntu 23.04 x86_64", - "ami_name": "salt-project/ci/ubuntu/23.04/x86_64/20231126.1417", + "ami_name": "salt-project/ci/ubuntu/23.04/x86_64/20240209.1843", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.large", @@ -380,9 +300,9 @@ "ssh_username": "ubuntu" }, "windows-2016": { - "ami": "ami-043db64b3b46a804c", + "ami": "ami-015acc248b175fb3c", "ami_description": "CI Image of Windows 2016 x86_64", - "ami_name": "salt-project/ci/windows/2016/x86_64/20231126.1417", + "ami_name": "salt-project/ci/windows/2016/x86_64/20240209.1844", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.xlarge", @@ -390,9 +310,9 @@ "ssh_username": "Administrator" }, "windows-2019": { - "ami": "ami-0f7a8dc8862bff13f", + "ami": "ami-0318f14f8690bf17f", "ami_description": "CI Image of Windows 2019 x86_64", - "ami_name": "salt-project/ci/windows/2019/x86_64/20231126.1417", + "ami_name": "salt-project/ci/windows/2019/x86_64/20240209.1844", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.xlarge", @@ -400,9 +320,9 @@ "ssh_username": "Administrator" }, "windows-2022": { - "ami": "ami-05a829f3649aa33d6", + "ami": "ami-0a78a28f614a662ad", "ami_description": "CI Image of Windows 2022 x86_64", - "ami_name": "salt-project/ci/windows/2022/x86_64/20231126.1417", + "ami_name": "salt-project/ci/windows/2022/x86_64/20240209.1844", "arch": "x86_64", "cloudwatch-agent-available": "true", "instance_type": "t3a.xlarge", diff --git a/noxfile.py b/noxfile.py index 4fa2b1a792d..f190e566938 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1308,7 +1308,7 @@ def decompress_dependencies(session): # Let's try to fix shebang's try: fpath = pathlib.Path(path) - contents = fpath.read_text().splitlines() + contents = fpath.read_text(encoding="utf-8").splitlines() if ( contents[0].startswith("#!") and contents[0].endswith("python") @@ -1318,7 +1318,9 @@ def decompress_dependencies(session): "Fixing broken shebang in %r", str(fpath.relative_to(REPO_ROOT)), ) - fpath.write_text("\n".join([fixed_shebang] + contents[1:])) + fpath.write_text( + "\n".join([fixed_shebang] + contents[1:]), encoding="utf-8" + ) except UnicodeDecodeError: pass @@ -1475,9 +1477,7 @@ class Tee: return self._first.fileno() -def _lint( - session, rcfile, flags, paths, tee_output=True, upgrade_setuptools_and_pip=True -): +def _lint(session, rcfile, flags, paths, upgrade_setuptools_and_pip=True): if _upgrade_pip_setuptools_and_wheel(session, upgrade=upgrade_setuptools_and_pip): linux_requirements_file = os.path.join( "requirements", "static", "ci", _get_pydir(session), "linux.txt" @@ -1494,38 +1494,9 @@ def _lint( ] session.install(*install_command, silent=PIP_INSTALL_SILENT) - if tee_output: - session.run("pylint", "--version") - pylint_report_path = os.environ.get("PYLINT_REPORT") - cmd_args = ["pylint", f"--rcfile={rcfile}"] + list(flags) + list(paths) - cmd_kwargs = {"env": {"PYTHONUNBUFFERED": "1"}} - - if tee_output: - stdout = tempfile.TemporaryFile(mode="w+b") - cmd_kwargs["stdout"] = Tee(stdout, sys.__stdout__) - - lint_failed = False - try: - session.run(*cmd_args, **cmd_kwargs) - except CommandFailed: - lint_failed = True - raise - finally: - if tee_output: - stdout.seek(0) - contents = stdout.read() - if contents: - contents = contents.decode("utf-8") - sys.stdout.write(contents) - sys.stdout.flush() - if pylint_report_path: - # Write report - with open(pylint_report_path, "w") as wfh: - wfh.write(contents) - session.log("Report file written to %r", pylint_report_path) - stdout.close() + session.run(*cmd_args, **cmd_kwargs) def _lint_pre_commit(session, rcfile, flags, paths): @@ -1544,26 +1515,17 @@ def _lint_pre_commit(session, rcfile, flags, paths): from nox.virtualenv import VirtualEnv # Let's patch nox to make it run inside the pre-commit virtualenv - try: - session._runner.venv = VirtualEnv( # pylint: disable=unexpected-keyword-arg - os.environ["VIRTUAL_ENV"], - interpreter=session._runner.func.python, - reuse_existing=True, - venv=True, - ) - except TypeError: - # This is still nox-py2 - session._runner.venv = VirtualEnv( - os.environ["VIRTUAL_ENV"], - interpreter=session._runner.func.python, - reuse_existing=True, - ) + session._runner.venv = VirtualEnv( + os.environ["VIRTUAL_ENV"], + interpreter=session._runner.func.python, + reuse_existing=True, + venv=True, + ) _lint( session, rcfile, flags, paths, - tee_output=False, upgrade_setuptools_and_pip=False, ) @@ -1571,7 +1533,7 @@ def _lint_pre_commit(session, rcfile, flags, paths): @nox.session(python="3") def lint(session): """ - Run PyLint against Salt and it's test suite. Set PYLINT_REPORT to a path to capture output. + Run PyLint against Salt and it's test suite. """ session.notify(f"lint-salt-{session.python}") session.notify(f"lint-tests-{session.python}") @@ -1580,21 +1542,21 @@ def lint(session): @nox.session(python="3", name="lint-salt") def lint_salt(session): """ - Run PyLint against Salt. Set PYLINT_REPORT to a path to capture output. + Run PyLint against Salt. """ flags = ["--disable=I"] if session.posargs: paths = session.posargs else: # TBD replace paths entries when implement pyproject.toml - paths = ["setup.py", "noxfile.py", "salt/"] + paths = ["setup.py", "noxfile.py", "salt/", "tools/"] _lint(session, ".pylintrc", flags, paths) @nox.session(python="3", name="lint-tests") def lint_tests(session): """ - Run PyLint against Salt and it's test suite. Set PYLINT_REPORT to a path to capture output. + Run PyLint against Salt and it's test suite. """ flags = ["--disable=I"] if session.posargs: @@ -1607,20 +1569,20 @@ def lint_tests(session): @nox.session(python=False, name="lint-salt-pre-commit") def lint_salt_pre_commit(session): """ - Run PyLint against Salt. Set PYLINT_REPORT to a path to capture output. + Run PyLint against Salt. """ flags = ["--disable=I"] if session.posargs: paths = session.posargs else: - paths = ["setup.py", "noxfile.py", "salt/"] + paths = ["setup.py", "noxfile.py", "salt/", "tools/"] _lint_pre_commit(session, ".pylintrc", flags, paths) @nox.session(python=False, name="lint-tests-pre-commit") def lint_tests_pre_commit(session): """ - Run PyLint against Salt and it's test suite. Set PYLINT_REPORT to a path to capture output. + Run PyLint against Salt and it's test suite. """ flags = ["--disable=I"] if session.posargs: @@ -2007,8 +1969,8 @@ def ci_test_onedir_pkgs(session): + cmd_args[:] + [ "--no-install", - f"--junitxml=artifacts/xml-unittests-output/test-results-install.xml", - f"--log-file=artifacts/logs/runtests-install.log", + "--junitxml=artifacts/xml-unittests-output/test-results-install.xml", + "--log-file=artifacts/logs/runtests-install.log", ] + session.posargs ) @@ -2025,8 +1987,8 @@ def ci_test_onedir_pkgs(session): + cmd_args[:] + [ "--no-install", - f"--junitxml=artifacts/xml-unittests-output/test-results-install-rerun.xml", - f"--log-file=artifacts/logs/runtests-install-rerun.log", + "--junitxml=artifacts/xml-unittests-output/test-results-install-rerun.xml", + "--log-file=artifacts/logs/runtests-install-rerun.log", "--lf", ] + session.posargs diff --git a/requirements/static/ci/lint.in b/requirements/static/ci/lint.in index 7b007abc24f..615bf80187e 100644 --- a/requirements/static/ci/lint.in +++ b/requirements/static/ci/lint.in @@ -2,6 +2,7 @@ --constraint=./py{py_version}/{platform}.txt -pylint==2.4.4 -SaltPyLint>=2023.3.8 +docker +pylint~=3.1.0 +SaltPyLint>=2024.2.2 toml diff --git a/requirements/static/ci/py3.10/cloud.txt b/requirements/static/ci/py3.10/cloud.txt index ca0cd5c5dc2..d1c5c0003e5 100644 --- a/requirements/static/ci/py3.10/cloud.txt +++ b/requirements/static/ci/py3.10/cloud.txt @@ -20,7 +20,7 @@ charset-normalizer==3.2.0 # via # -c requirements/static/ci/py3.10/linux.txt # requests -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/py3.10/linux.txt # pyspnego diff --git a/requirements/static/ci/py3.10/darwin.txt b/requirements/static/ci/py3.10/darwin.txt index cab75542dbf..9cb0c58b577 100644 --- a/requirements/static/ci/py3.10/darwin.txt +++ b/requirements/static/ci/py3.10/darwin.txt @@ -97,7 +97,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.10/darwin.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.10/freebsd.txt b/requirements/static/ci/py3.10/freebsd.txt index 1a51e9234f5..95a9959ccd7 100644 --- a/requirements/static/ci/py3.10/freebsd.txt +++ b/requirements/static/ci/py3.10/freebsd.txt @@ -96,7 +96,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.10/freebsd.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.10/lint.txt b/requirements/static/ci/py3.10/lint.txt index 26e0b8abffc..8db0bcd9ad0 100644 --- a/requirements/static/ci/py3.10/lint.txt +++ b/requirements/static/ci/py3.10/lint.txt @@ -4,31 +4,72 @@ # # pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.10/lint.txt requirements/static/ci/lint.in # -astroid==2.3.3 +astroid==3.1.0 # via pylint +certifi==2023.07.22 + # via + # -c requirements/static/ci/py3.10/linux.txt + # requests +charset-normalizer==3.2.0 + # via + # -c requirements/static/ci/py3.10/linux.txt + # requests +dill==0.3.8 + # via pylint +docker==6.1.3 + # via + # -c requirements/static/ci/py3.10/linux.txt + # -r requirements/static/ci/lint.in +idna==3.4 + # via + # -c requirements/static/ci/py3.10/linux.txt + # requests isort==4.3.21 # via pylint -lazy-object-proxy==1.4.3 - # via astroid mccabe==0.6.1 # via pylint -modernize==0.5 - # via saltpylint -pycodestyle==2.10.0 - # via saltpylint -pylint==2.4.4 +packaging==23.1 + # via + # -c requirements/static/ci/py3.10/linux.txt + # docker +platformdirs==4.0.0 + # via + # -c requirements/static/ci/py3.10/linux.txt + # pylint +pylint==3.1.0 # via # -r requirements/static/ci/lint.in # saltpylint -saltpylint==2023.8.3 +requests==2.31.0 + # via + # -c requirements/static/ci/py3.10/linux.txt + # docker +saltpylint==2024.2.5 # via -r requirements/static/ci/lint.in six==1.16.0 # via # -c requirements/static/ci/py3.10/linux.txt - # astroid + # websocket-client toml==0.10.2 # via # -c requirements/static/ci/py3.10/linux.txt # -r requirements/static/ci/lint.in -wrapt==1.11.2 - # via astroid +tomli==2.0.1 + # via + # -c requirements/static/ci/py3.10/linux.txt + # pylint +tomlkit==0.12.3 + # via pylint +typing-extensions==4.8.0 + # via + # -c requirements/static/ci/py3.10/linux.txt + # astroid +urllib3==1.26.18 + # via + # -c requirements/static/ci/py3.10/linux.txt + # docker + # requests +websocket-client==0.40.0 + # via + # -c requirements/static/ci/py3.10/linux.txt + # docker diff --git a/requirements/static/ci/py3.10/linux.txt b/requirements/static/ci/py3.10/linux.txt index 82b238aface..8a135e07a0a 100644 --- a/requirements/static/ci/py3.10/linux.txt +++ b/requirements/static/ci/py3.10/linux.txt @@ -109,7 +109,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.10/linux.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.10/tools.txt b/requirements/static/ci/py3.10/tools.txt index 3595e5a0106..e1f68b3206f 100644 --- a/requirements/static/ci/py3.10/tools.txt +++ b/requirements/static/ci/py3.10/tools.txt @@ -4,7 +4,9 @@ # # pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.10/tools.txt requirements/static/ci/tools.in # -attrs==23.2.0 +annotated-types==0.6.0 + # via pydantic +attrs==20.3.0 # via # -r requirements/static/ci/tools.in # python-tools-scripts @@ -34,11 +36,15 @@ mdurl==0.1.2 # via markdown-it-py packaging==23.1 # via -r requirements/static/ci/tools.in -pygments==2.15.1 +pydantic-core==2.16.2 + # via pydantic +pydantic==2.6.1 + # via python-tools-scripts +pygments==2.13.0 # via rich python-dateutil==2.8.2 # via botocore -python-tools-scripts==0.18.6 +python-tools-scripts==0.20.0 # via -r requirements/static/ci/tools.in pyyaml==6.0.1 # via -r requirements/static/ci/tools.in @@ -50,8 +56,11 @@ s3transfer==0.6.1 # via boto3 six==1.16.0 # via python-dateutil -typing-extensions==4.2.0 - # via python-tools-scripts +typing-extensions==4.9.0 + # via + # pydantic + # pydantic-core + # python-tools-scripts urllib3==1.26.18 # via # botocore diff --git a/requirements/static/ci/py3.10/windows.txt b/requirements/static/ci/py3.10/windows.txt index 98868aacb97..8a4cd5ea1b0 100644 --- a/requirements/static/ci/py3.10/windows.txt +++ b/requirements/static/ci/py3.10/windows.txt @@ -93,7 +93,7 @@ contextvars==2.4 # via # -c requirements/static/ci/../pkg/py3.10/windows.txt # -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.10/windows.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.11/cloud.txt b/requirements/static/ci/py3.11/cloud.txt index 8500afc4533..ede2f925742 100644 --- a/requirements/static/ci/py3.11/cloud.txt +++ b/requirements/static/ci/py3.11/cloud.txt @@ -20,7 +20,7 @@ charset-normalizer==3.2.0 # via # -c requirements/static/ci/py3.11/linux.txt # requests -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/py3.11/linux.txt # pyspnego diff --git a/requirements/static/ci/py3.11/darwin.txt b/requirements/static/ci/py3.11/darwin.txt index e8e9e1446ba..4534837c586 100644 --- a/requirements/static/ci/py3.11/darwin.txt +++ b/requirements/static/ci/py3.11/darwin.txt @@ -96,7 +96,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.11/darwin.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.11/freebsd.txt b/requirements/static/ci/py3.11/freebsd.txt index 97687e80ba5..2e13ced6146 100644 --- a/requirements/static/ci/py3.11/freebsd.txt +++ b/requirements/static/ci/py3.11/freebsd.txt @@ -95,7 +95,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.11/freebsd.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.11/lint.txt b/requirements/static/ci/py3.11/lint.txt index fc60fa5b411..8272237673d 100644 --- a/requirements/static/ci/py3.11/lint.txt +++ b/requirements/static/ci/py3.11/lint.txt @@ -4,31 +4,64 @@ # # pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.11/lint.txt requirements/static/ci/lint.in # -astroid==2.3.3 +astroid==3.1.0 # via pylint +certifi==2023.07.22 + # via + # -c requirements/static/ci/py3.11/linux.txt + # requests +charset-normalizer==3.2.0 + # via + # -c requirements/static/ci/py3.11/linux.txt + # requests +dill==0.3.8 + # via pylint +docker==6.1.3 + # via + # -c requirements/static/ci/py3.11/linux.txt + # -r requirements/static/ci/lint.in +idna==3.4 + # via + # -c requirements/static/ci/py3.11/linux.txt + # requests isort==4.3.21 # via pylint -lazy-object-proxy==1.4.3 - # via astroid mccabe==0.6.1 # via pylint -modernize==0.5 - # via saltpylint -pycodestyle==2.10.0 - # via saltpylint -pylint==2.4.4 +packaging==23.1 + # via + # -c requirements/static/ci/py3.11/linux.txt + # docker +platformdirs==4.0.0 + # via + # -c requirements/static/ci/py3.11/linux.txt + # pylint +pylint==3.1.0 # via # -r requirements/static/ci/lint.in # saltpylint -saltpylint==2023.8.3 +requests==2.31.0 + # via + # -c requirements/static/ci/py3.11/linux.txt + # docker +saltpylint==2024.2.5 # via -r requirements/static/ci/lint.in six==1.16.0 # via # -c requirements/static/ci/py3.11/linux.txt - # astroid + # websocket-client toml==0.10.2 # via # -c requirements/static/ci/py3.11/linux.txt # -r requirements/static/ci/lint.in -wrapt==1.11.2 - # via astroid +tomlkit==0.12.3 + # via pylint +urllib3==1.26.18 + # via + # -c requirements/static/ci/py3.11/linux.txt + # docker + # requests +websocket-client==0.40.0 + # via + # -c requirements/static/ci/py3.11/linux.txt + # docker diff --git a/requirements/static/ci/py3.11/linux.txt b/requirements/static/ci/py3.11/linux.txt index b7813920400..461353c9d8b 100644 --- a/requirements/static/ci/py3.11/linux.txt +++ b/requirements/static/ci/py3.11/linux.txt @@ -108,7 +108,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.11/linux.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.11/tools.txt b/requirements/static/ci/py3.11/tools.txt index 25849db76d4..7fa8c5427ed 100644 --- a/requirements/static/ci/py3.11/tools.txt +++ b/requirements/static/ci/py3.11/tools.txt @@ -4,7 +4,9 @@ # # pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.11/tools.txt requirements/static/ci/tools.in # -attrs==23.2.0 +annotated-types==0.6.0 + # via pydantic +attrs==22.1.0 # via # -r requirements/static/ci/tools.in # python-tools-scripts @@ -34,11 +36,15 @@ mdurl==0.1.2 # via markdown-it-py packaging==23.1 # via -r requirements/static/ci/tools.in +pydantic-core==2.16.2 + # via pydantic +pydantic==2.6.1 + # via python-tools-scripts pygments==2.15.1 # via rich python-dateutil==2.8.2 # via botocore -python-tools-scripts==0.18.6 +python-tools-scripts==0.20.0 # via -r requirements/static/ci/tools.in pyyaml==6.0.1 # via -r requirements/static/ci/tools.in @@ -50,6 +56,10 @@ s3transfer==0.6.1 # via boto3 six==1.16.0 # via python-dateutil +typing-extensions==4.9.0 + # via + # pydantic + # pydantic-core urllib3==1.26.18 # via # botocore diff --git a/requirements/static/ci/py3.11/windows.txt b/requirements/static/ci/py3.11/windows.txt index df58b6726f8..6fac0db3291 100644 --- a/requirements/static/ci/py3.11/windows.txt +++ b/requirements/static/ci/py3.11/windows.txt @@ -92,7 +92,7 @@ contextvars==2.4 # via # -c requirements/static/ci/../pkg/py3.11/windows.txt # -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.11/windows.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.12/cloud.txt b/requirements/static/ci/py3.12/cloud.txt index 51a9271f1ef..53cb9152f3d 100644 --- a/requirements/static/ci/py3.12/cloud.txt +++ b/requirements/static/ci/py3.12/cloud.txt @@ -129,7 +129,7 @@ croniter==1.3.15 ; sys_platform != "win32" # via # -c requirements/static/ci/py3.12/linux.txt # -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.12/linux.txt # -c requirements/static/ci/py3.12/linux.txt diff --git a/requirements/static/ci/py3.12/darwin.txt b/requirements/static/ci/py3.12/darwin.txt index b5ccf298201..e3927615ba0 100644 --- a/requirements/static/ci/py3.12/darwin.txt +++ b/requirements/static/ci/py3.12/darwin.txt @@ -96,7 +96,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.12/darwin.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.12/docs.txt b/requirements/static/ci/py3.12/docs.txt index 702a7d6a047..4f23bb76a7e 100644 --- a/requirements/static/ci/py3.12/docs.txt +++ b/requirements/static/ci/py3.12/docs.txt @@ -53,7 +53,7 @@ contextvars==2.4 # via # -c requirements/static/ci/py3.12/linux.txt # -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/py3.12/linux.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.12/freebsd.txt b/requirements/static/ci/py3.12/freebsd.txt index 830bebc43e2..2ae6a9dbe27 100644 --- a/requirements/static/ci/py3.12/freebsd.txt +++ b/requirements/static/ci/py3.12/freebsd.txt @@ -95,7 +95,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.12/freebsd.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.12/lint.txt b/requirements/static/ci/py3.12/lint.txt index d1208e80b39..ad19bd8bf87 100644 --- a/requirements/static/ci/py3.12/lint.txt +++ b/requirements/static/ci/py3.12/lint.txt @@ -47,7 +47,7 @@ asn1crypto==1.5.1 # -c requirements/static/ci/py3.12/linux.txt # certvalidator # oscrypto -astroid==2.3.3 +astroid==3.1.0 # via pylint attrs==23.2.0 # via @@ -147,7 +147,7 @@ croniter==1.3.15 ; sys_platform != "win32" # via # -c requirements/static/ci/py3.12/linux.txt # -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.12/linux.txt # -c requirements/static/ci/py3.12/linux.txt @@ -158,6 +158,8 @@ cryptography==42.0.3 # paramiko # pyopenssl # vcert +dill==0.3.8 + # via pylint distlib==0.3.8 # via # -c requirements/static/ci/py3.12/linux.txt @@ -172,6 +174,10 @@ dnspython==2.3.0 # -c requirements/static/ci/py3.12/linux.txt # -r requirements/static/ci/common.in # python-etcd +docker==6.1.3 + # via + # -c requirements/static/ci/py3.12/linux.txt + # -r requirements/static/ci/lint.in etcd3-py==0.1.6 # via # -c requirements/static/ci/py3.12/linux.txt @@ -325,8 +331,6 @@ kubernetes==3.0.0 # via # -c requirements/static/ci/py3.12/linux.txt # -r requirements/static/ci/common.in -lazy-object-proxy==1.4.3 - # via astroid libnacl==1.8.0 ; sys_platform != "win32" and sys_platform != "darwin" # via # -c requirements/static/ci/py3.12/linux.txt @@ -361,8 +365,6 @@ mercurial==6.0.1 # via # -c requirements/static/ci/py3.12/linux.txt # -r requirements/static/ci/linux.in -modernize==0.5 - # via saltpylint more-itertools==5.0.0 # via # -c requirements/static/ci/../pkg/py3.12/linux.txt @@ -423,6 +425,7 @@ packaging==23.1 # -c requirements/static/ci/py3.12/linux.txt # -r requirements/base.txt # ansible-core + # docker paramiko==3.4.0 ; sys_platform != "win32" and sys_platform != "darwin" # via # -c requirements/static/ci/py3.12/linux.txt @@ -443,6 +446,7 @@ pathspec==0.11.1 platformdirs==4.0.0 # via # -c requirements/static/ci/py3.12/linux.txt + # pylint # virtualenv portend==3.1.0 # via @@ -463,8 +467,6 @@ pyasn1==0.5.1 # -c requirements/static/ci/py3.12/linux.txt # pyasn1-modules # rsa -pycodestyle==2.10.0 - # via saltpylint pycparser==2.21 # via # -c requirements/static/ci/../pkg/py3.12/linux.txt @@ -505,7 +507,7 @@ pyjwt==2.4.0 # via # -c requirements/static/ci/py3.12/linux.txt # twilio -pylint==2.4.4 +pylint==3.1.0 # via # -r requirements/static/ci/lint.in # saltpylint @@ -608,6 +610,7 @@ requests==2.31.0 # -r requirements/base.txt # -r requirements/static/ci/common.in # apache-libcloud + # docker # etcd3-py # kubernetes # moto @@ -641,7 +644,7 @@ s3transfer==0.6.1 # via # -c requirements/static/ci/py3.12/linux.txt # boto3 -saltpylint==2023.8.3 +saltpylint==2024.2.5 # via -r requirements/static/ci/lint.in scp==0.14.5 # via @@ -662,7 +665,6 @@ six==1.16.0 # via # -c requirements/static/ci/../pkg/py3.12/linux.txt # -c requirements/static/ci/py3.12/linux.txt - # astroid # cassandra-driver # etcd3-py # genshi @@ -728,6 +730,8 @@ toml==0.10.2 # -c requirements/static/ci/py3.12/linux.txt # -r requirements/static/ci/common.in # -r requirements/static/ci/lint.in +tomlkit==0.12.3 + # via pylint tornado==6.3.3 # via # -c requirements/static/ci/../pkg/py3.12/linux.txt @@ -767,6 +771,7 @@ urllib3==1.26.18 # -c requirements/static/ci/../pkg/py3.12/linux.txt # -c requirements/static/ci/py3.12/linux.txt # botocore + # docker # kubernetes # python-etcd # requests @@ -786,6 +791,7 @@ watchdog==3.0.0 websocket-client==0.40.0 # via # -c requirements/static/ci/py3.12/linux.txt + # docker # kubernetes wempy==0.2.1 # via @@ -795,8 +801,6 @@ werkzeug==3.0.1 # via # -c requirements/static/ci/py3.12/linux.txt # moto -wrapt==1.11.2 - # via astroid xmldiff==2.6.3 # via # -c requirements/static/ci/py3.12/linux.txt diff --git a/requirements/static/ci/py3.12/linux.txt b/requirements/static/ci/py3.12/linux.txt index 50d8102b62f..e1b49e3e9f7 100644 --- a/requirements/static/ci/py3.12/linux.txt +++ b/requirements/static/ci/py3.12/linux.txt @@ -108,7 +108,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.12/linux.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.12/tools.txt b/requirements/static/ci/py3.12/tools.txt index 3e495d5a5b8..ef7af45dc9a 100644 --- a/requirements/static/ci/py3.12/tools.txt +++ b/requirements/static/ci/py3.12/tools.txt @@ -4,7 +4,9 @@ # # pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.12/tools.txt requirements/static/ci/tools.in # -attrs==23.2.0 +annotated-types==0.6.0 + # via pydantic +attrs==22.1.0 # via # -r requirements/static/ci/tools.in # python-tools-scripts @@ -34,11 +36,15 @@ mdurl==0.1.2 # via markdown-it-py packaging==23.1 # via -r requirements/static/ci/tools.in +pydantic-core==2.16.2 + # via pydantic +pydantic==2.6.1 + # via python-tools-scripts pygments==2.15.1 # via rich python-dateutil==2.8.2 # via botocore -python-tools-scripts==0.18.6 +python-tools-scripts==0.20.0 # via -r requirements/static/ci/tools.in pyyaml==6.0.1 # via -r requirements/static/ci/tools.in @@ -50,6 +56,10 @@ s3transfer==0.6.1 # via boto3 six==1.16.0 # via python-dateutil +typing-extensions==4.9.0 + # via + # pydantic + # pydantic-core urllib3==1.26.18 # via # botocore diff --git a/requirements/static/ci/py3.12/windows.txt b/requirements/static/ci/py3.12/windows.txt index 4232423cb2c..dc687c865c9 100644 --- a/requirements/static/ci/py3.12/windows.txt +++ b/requirements/static/ci/py3.12/windows.txt @@ -92,7 +92,7 @@ contextvars==2.4 # via # -c requirements/static/ci/../pkg/py3.12/windows.txt # -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.12/windows.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.8/cloud.txt b/requirements/static/ci/py3.8/cloud.txt index b0b2d436b88..e6caac1247a 100644 --- a/requirements/static/ci/py3.8/cloud.txt +++ b/requirements/static/ci/py3.8/cloud.txt @@ -20,7 +20,7 @@ charset-normalizer==3.2.0 # via # -c requirements/static/ci/py3.8/linux.txt # requests -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/py3.8/linux.txt # pyspnego diff --git a/requirements/static/ci/py3.8/freebsd.txt b/requirements/static/ci/py3.8/freebsd.txt index f6368b8b7dc..a5dc3f1d7ac 100644 --- a/requirements/static/ci/py3.8/freebsd.txt +++ b/requirements/static/ci/py3.8/freebsd.txt @@ -96,7 +96,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.8/freebsd.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.8/lint.txt b/requirements/static/ci/py3.8/lint.txt index 0b75ee9a840..e37f30af402 100644 --- a/requirements/static/ci/py3.8/lint.txt +++ b/requirements/static/ci/py3.8/lint.txt @@ -4,31 +4,73 @@ # # pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.8/lint.txt requirements/static/ci/lint.in # -astroid==2.3.3 +astroid==3.1.0 # via pylint +certifi==2023.07.22 + # via + # -c requirements/static/ci/py3.8/linux.txt + # requests +charset-normalizer==3.2.0 + # via + # -c requirements/static/ci/py3.8/linux.txt + # requests +dill==0.3.8 + # via pylint +docker==6.1.3 + # via + # -c requirements/static/ci/py3.8/linux.txt + # -r requirements/static/ci/lint.in +idna==3.4 + # via + # -c requirements/static/ci/py3.8/linux.txt + # requests isort==4.3.21 # via pylint -lazy-object-proxy==1.4.3 - # via astroid mccabe==0.6.1 # via pylint -modernize==0.5 - # via saltpylint -pycodestyle==2.10.0 - # via saltpylint -pylint==2.4.4 +packaging==23.1 + # via + # -c requirements/static/ci/py3.8/linux.txt + # docker +platformdirs==4.0.0 + # via + # -c requirements/static/ci/py3.8/linux.txt + # pylint +pylint==3.1.0 # via # -r requirements/static/ci/lint.in # saltpylint -saltpylint==2023.8.3 +requests==2.31.0 + # via + # -c requirements/static/ci/py3.8/linux.txt + # docker +saltpylint==2024.2.5 # via -r requirements/static/ci/lint.in six==1.16.0 # via # -c requirements/static/ci/py3.8/linux.txt - # astroid + # websocket-client toml==0.10.2 # via # -c requirements/static/ci/py3.8/linux.txt # -r requirements/static/ci/lint.in -wrapt==1.11.2 - # via astroid +tomli==2.0.1 + # via + # -c requirements/static/ci/py3.8/linux.txt + # pylint +tomlkit==0.12.3 + # via pylint +typing-extensions==4.8.0 + # via + # -c requirements/static/ci/py3.8/linux.txt + # astroid + # pylint +urllib3==1.26.18 + # via + # -c requirements/static/ci/py3.8/linux.txt + # docker + # requests +websocket-client==0.40.0 + # via + # -c requirements/static/ci/py3.8/linux.txt + # docker diff --git a/requirements/static/ci/py3.8/linux.txt b/requirements/static/ci/py3.8/linux.txt index 625167aef83..8dfe7d3e75e 100644 --- a/requirements/static/ci/py3.8/linux.txt +++ b/requirements/static/ci/py3.8/linux.txt @@ -105,7 +105,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.8/linux.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.8/windows.txt b/requirements/static/ci/py3.8/windows.txt index fbfb7355849..7e66631af01 100644 --- a/requirements/static/ci/py3.8/windows.txt +++ b/requirements/static/ci/py3.8/windows.txt @@ -93,7 +93,7 @@ contextvars==2.4 # via # -c requirements/static/ci/../pkg/py3.8/windows.txt # -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.8/windows.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.9/cloud.txt b/requirements/static/ci/py3.9/cloud.txt index 338b4f7b952..fbed2f95c05 100644 --- a/requirements/static/ci/py3.9/cloud.txt +++ b/requirements/static/ci/py3.9/cloud.txt @@ -20,7 +20,7 @@ charset-normalizer==3.2.0 # via # -c requirements/static/ci/py3.9/linux.txt # requests -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/py3.9/linux.txt # pyspnego diff --git a/requirements/static/ci/py3.9/darwin.txt b/requirements/static/ci/py3.9/darwin.txt index 0d03b780c73..c159f036c52 100644 --- a/requirements/static/ci/py3.9/darwin.txt +++ b/requirements/static/ci/py3.9/darwin.txt @@ -97,7 +97,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.9/darwin.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.9/freebsd.txt b/requirements/static/ci/py3.9/freebsd.txt index 9e9bd6f66a3..9ce94d55cff 100644 --- a/requirements/static/ci/py3.9/freebsd.txt +++ b/requirements/static/ci/py3.9/freebsd.txt @@ -96,7 +96,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.9/freebsd.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.9/lint.txt b/requirements/static/ci/py3.9/lint.txt index 13375d3d20e..6503faed8db 100644 --- a/requirements/static/ci/py3.9/lint.txt +++ b/requirements/static/ci/py3.9/lint.txt @@ -4,31 +4,73 @@ # # pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.9/lint.txt requirements/static/ci/lint.in # -astroid==2.3.3 +astroid==3.1.0 # via pylint +certifi==2023.07.22 + # via + # -c requirements/static/ci/py3.9/linux.txt + # requests +charset-normalizer==3.2.0 + # via + # -c requirements/static/ci/py3.9/linux.txt + # requests +dill==0.3.8 + # via pylint +docker==6.1.3 + # via + # -c requirements/static/ci/py3.9/linux.txt + # -r requirements/static/ci/lint.in +idna==3.4 + # via + # -c requirements/static/ci/py3.9/linux.txt + # requests isort==4.3.21 # via pylint -lazy-object-proxy==1.4.3 - # via astroid mccabe==0.6.1 # via pylint -modernize==0.5 - # via saltpylint -pycodestyle==2.10.0 - # via saltpylint -pylint==2.4.4 +packaging==23.1 + # via + # -c requirements/static/ci/py3.9/linux.txt + # docker +platformdirs==4.0.0 + # via + # -c requirements/static/ci/py3.9/linux.txt + # pylint +pylint==3.1.0 # via # -r requirements/static/ci/lint.in # saltpylint -saltpylint==2023.8.3 +requests==2.31.0 + # via + # -c requirements/static/ci/py3.9/linux.txt + # docker +saltpylint==2024.2.5 # via -r requirements/static/ci/lint.in six==1.16.0 # via # -c requirements/static/ci/py3.9/linux.txt - # astroid + # websocket-client toml==0.10.2 # via # -c requirements/static/ci/py3.9/linux.txt # -r requirements/static/ci/lint.in -wrapt==1.11.2 - # via astroid +tomli==2.0.1 + # via + # -c requirements/static/ci/py3.9/linux.txt + # pylint +tomlkit==0.12.3 + # via pylint +typing-extensions==4.8.0 + # via + # -c requirements/static/ci/py3.9/linux.txt + # astroid + # pylint +urllib3==1.26.18 + # via + # -c requirements/static/ci/py3.9/linux.txt + # docker + # requests +websocket-client==0.40.0 + # via + # -c requirements/static/ci/py3.9/linux.txt + # docker diff --git a/requirements/static/ci/py3.9/linux.txt b/requirements/static/ci/py3.9/linux.txt index 1c527e862a9..c200e264c10 100644 --- a/requirements/static/ci/py3.9/linux.txt +++ b/requirements/static/ci/py3.9/linux.txt @@ -105,7 +105,7 @@ contextvars==2.4 # -r requirements/base.txt croniter==1.3.15 ; sys_platform != "win32" # via -r requirements/static/ci/common.in -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.9/linux.txt # -r requirements/base.txt diff --git a/requirements/static/ci/py3.9/tools.txt b/requirements/static/ci/py3.9/tools.txt index f7b9f26cea9..5ba45e10467 100644 --- a/requirements/static/ci/py3.9/tools.txt +++ b/requirements/static/ci/py3.9/tools.txt @@ -4,7 +4,9 @@ # # pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.9/tools.txt requirements/static/ci/tools.in # -attrs==23.2.0 +annotated-types==0.6.0 + # via pydantic +attrs==20.3.0 # via # -r requirements/static/ci/tools.in # python-tools-scripts @@ -34,11 +36,15 @@ mdurl==0.1.2 # via markdown-it-py packaging==23.1 # via -r requirements/static/ci/tools.in -pygments==2.15.1 +pydantic-core==2.16.2 + # via pydantic +pydantic==2.6.1 + # via python-tools-scripts +pygments==2.13.0 # via rich python-dateutil==2.8.2 # via botocore -python-tools-scripts==0.18.6 +python-tools-scripts==0.20.0 # via -r requirements/static/ci/tools.in pyyaml==6.0.1 # via -r requirements/static/ci/tools.in @@ -50,8 +56,11 @@ s3transfer==0.6.1 # via boto3 six==1.16.0 # via python-dateutil -typing-extensions==4.2.0 - # via python-tools-scripts +typing-extensions==4.9.0 + # via + # pydantic + # pydantic-core + # python-tools-scripts urllib3==1.26.18 # via # botocore diff --git a/requirements/static/ci/py3.9/windows.txt b/requirements/static/ci/py3.9/windows.txt index 60b2ce6628f..7561c3c935f 100644 --- a/requirements/static/ci/py3.9/windows.txt +++ b/requirements/static/ci/py3.9/windows.txt @@ -93,7 +93,7 @@ contextvars==2.4 # via # -c requirements/static/ci/../pkg/py3.9/windows.txt # -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -c requirements/static/ci/../pkg/py3.9/windows.txt # -r requirements/base.txt diff --git a/requirements/static/ci/tools.in b/requirements/static/ci/tools.in index 7bc0163df05..5d0da3fde92 100644 --- a/requirements/static/ci/tools.in +++ b/requirements/static/ci/tools.in @@ -1,5 +1,5 @@ attrs -python-tools-scripts >= 0.18.6 +python-tools-scripts >= 0.20.0 boto3 pyyaml jinja2 diff --git a/requirements/static/pkg/py3.10/darwin.txt b/requirements/static/pkg/py3.10/darwin.txt index 38ad70a61a4..0551af91df2 100644 --- a/requirements/static/pkg/py3.10/darwin.txt +++ b/requirements/static/pkg/py3.10/darwin.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.10/freebsd.txt b/requirements/static/pkg/py3.10/freebsd.txt index 1df9138f4ca..9f30c8b034c 100644 --- a/requirements/static/pkg/py3.10/freebsd.txt +++ b/requirements/static/pkg/py3.10/freebsd.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.10/linux.txt b/requirements/static/pkg/py3.10/linux.txt index f6ec80d42f5..14a630022eb 100644 --- a/requirements/static/pkg/py3.10/linux.txt +++ b/requirements/static/pkg/py3.10/linux.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.10/windows.txt b/requirements/static/pkg/py3.10/windows.txt index 7e0e6a9ef3e..e8300cdf304 100644 --- a/requirements/static/pkg/py3.10/windows.txt +++ b/requirements/static/pkg/py3.10/windows.txt @@ -30,7 +30,7 @@ clr-loader==0.2.6 # via pythonnet contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.11/darwin.txt b/requirements/static/pkg/py3.11/darwin.txt index 782bfa74659..1f34b68c00e 100644 --- a/requirements/static/pkg/py3.11/darwin.txt +++ b/requirements/static/pkg/py3.11/darwin.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.11/freebsd.txt b/requirements/static/pkg/py3.11/freebsd.txt index 2f50335e4d3..3d95c774bbc 100644 --- a/requirements/static/pkg/py3.11/freebsd.txt +++ b/requirements/static/pkg/py3.11/freebsd.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.11/linux.txt b/requirements/static/pkg/py3.11/linux.txt index cda0f6d7855..a7a82efdf19 100644 --- a/requirements/static/pkg/py3.11/linux.txt +++ b/requirements/static/pkg/py3.11/linux.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.11/windows.txt b/requirements/static/pkg/py3.11/windows.txt index 87732667a3b..5ae14a35ead 100644 --- a/requirements/static/pkg/py3.11/windows.txt +++ b/requirements/static/pkg/py3.11/windows.txt @@ -30,7 +30,7 @@ clr-loader==0.2.6 # via pythonnet contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.12/darwin.txt b/requirements/static/pkg/py3.12/darwin.txt index 0887c0566ff..6a74eaead1e 100644 --- a/requirements/static/pkg/py3.12/darwin.txt +++ b/requirements/static/pkg/py3.12/darwin.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.12/freebsd.txt b/requirements/static/pkg/py3.12/freebsd.txt index e919af01af6..948d82482f0 100644 --- a/requirements/static/pkg/py3.12/freebsd.txt +++ b/requirements/static/pkg/py3.12/freebsd.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.12/linux.txt b/requirements/static/pkg/py3.12/linux.txt index 329fb2d36ec..6f1bea999d1 100644 --- a/requirements/static/pkg/py3.12/linux.txt +++ b/requirements/static/pkg/py3.12/linux.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.12/windows.txt b/requirements/static/pkg/py3.12/windows.txt index 5f73e99ef6c..dae4f6db001 100644 --- a/requirements/static/pkg/py3.12/windows.txt +++ b/requirements/static/pkg/py3.12/windows.txt @@ -30,7 +30,7 @@ clr-loader==0.2.6 # via pythonnet contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.8/freebsd.txt b/requirements/static/pkg/py3.8/freebsd.txt index 3d3ee1a14c9..e84cb9fe2bf 100644 --- a/requirements/static/pkg/py3.8/freebsd.txt +++ b/requirements/static/pkg/py3.8/freebsd.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.8/linux.txt b/requirements/static/pkg/py3.8/linux.txt index 7e585081e21..f7d0b2d1e36 100644 --- a/requirements/static/pkg/py3.8/linux.txt +++ b/requirements/static/pkg/py3.8/linux.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.8/windows.txt b/requirements/static/pkg/py3.8/windows.txt index 30d37748787..3f9149abfd9 100644 --- a/requirements/static/pkg/py3.8/windows.txt +++ b/requirements/static/pkg/py3.8/windows.txt @@ -30,7 +30,7 @@ clr-loader==0.2.6 # via pythonnet contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.9/darwin.txt b/requirements/static/pkg/py3.9/darwin.txt index b6707a54874..9933780a0b8 100644 --- a/requirements/static/pkg/py3.9/darwin.txt +++ b/requirements/static/pkg/py3.9/darwin.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.9/freebsd.txt b/requirements/static/pkg/py3.9/freebsd.txt index 0a4670693c8..a000d3649bb 100644 --- a/requirements/static/pkg/py3.9/freebsd.txt +++ b/requirements/static/pkg/py3.9/freebsd.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.9/linux.txt b/requirements/static/pkg/py3.9/linux.txt index f9d03477f6b..5762ac259a1 100644 --- a/requirements/static/pkg/py3.9/linux.txt +++ b/requirements/static/pkg/py3.9/linux.txt @@ -26,7 +26,7 @@ cherrypy==18.8.0 # via -r requirements/base.txt contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/requirements/static/pkg/py3.9/windows.txt b/requirements/static/pkg/py3.9/windows.txt index 411dc77a715..c07e82f67ed 100644 --- a/requirements/static/pkg/py3.9/windows.txt +++ b/requirements/static/pkg/py3.9/windows.txt @@ -30,7 +30,7 @@ clr-loader==0.2.6 # via pythonnet contextvars==2.4 # via -r requirements/base.txt -cryptography==42.0.3 +cryptography==42.0.5 # via # -r requirements/base.txt # pyopenssl diff --git a/salt/__init__.py b/salt/__init__.py index 3d36a148f7f..81e654d0c9f 100644 --- a/salt/__init__.py +++ b/salt/__init__.py @@ -4,7 +4,6 @@ Salt package import asyncio import importlib -import locale import os import sys import warnings diff --git a/salt/_logging/impl.py b/salt/_logging/impl.py index 237a8a5c173..1d5927319d8 100644 --- a/salt/_logging/impl.py +++ b/salt/_logging/impl.py @@ -170,7 +170,7 @@ class SaltLoggingClass(LOGGING_LOGGER_CLASS, metaclass=LoggingMixinMeta): logging.getLogger(__name__) """ - instance = super().__new__(cls) + instance = super().__new__(cls) # pylint: disable=no-value-for-parameter try: max_logger_length = len( @@ -480,7 +480,7 @@ def setup_temp_handler(log_level=None): def tryflush(): try: - handler.flush() + handler.flush() # pylint: disable=cell-var-from-loop except ValueError: # File handle has already been closed. pass diff --git a/salt/auth/pki.py b/salt/auth/pki.py index f33e3ccf00c..1c9d6f205a2 100644 --- a/salt/auth/pki.py +++ b/salt/auth/pki.py @@ -84,11 +84,10 @@ def auth(username, password, **kwargs): if cert.verify(cacert.get_pubkey()): log.info("Successfully authenticated certificate: %s", pem) return True - else: - log.info("Failed to authenticate certificate: %s", pem) - return False + log.info("Failed to authenticate certificate: %s", pem) + return False - c = OpenSSL.crypto + c = OpenSSL.crypto # pylint: disable=used-before-assignment cert = c.load_certificate(c.FILETYPE_PEM, pem) with salt.utils.files.fopen(cacert_file) as f: @@ -101,7 +100,7 @@ def auth(username, password, **kwargs): cert_asn1 = c.dump_certificate(c.FILETYPE_ASN1, cert) # Decode the certificate - der = asn1.DerSequence() + der = asn1.DerSequence() # pylint: disable=used-before-assignment der.decode(cert_asn1) # The certificate has three parts: diff --git a/salt/beacons/network_info.py b/salt/beacons/network_info.py index 4d5743d20fb..8d2c94176ea 100644 --- a/salt/beacons/network_info.py +++ b/salt/beacons/network_info.py @@ -9,13 +9,12 @@ import logging import salt.utils.beacons try: - import salt.utils.psutil_compat as psutil + import psutil HAS_PSUTIL = True except ImportError: HAS_PSUTIL = False - log = logging.getLogger(__name__) __virtualname__ = "network_info" @@ -46,9 +45,10 @@ def _to_list(obj): def __virtual__(): if not HAS_PSUTIL: - err_msg = "psutil not available" - log.error("Unable to load %s beacon: %s", __virtualname__, err_msg) - return False, err_msg + return ( + False, + f"Unable to load {__virtualname__} beacon: psutil library not installed", + ) return __virtualname__ diff --git a/salt/beacons/ps.py b/salt/beacons/ps.py index a5d9aa3d91c..090a06b1235 100644 --- a/salt/beacons/ps.py +++ b/salt/beacons/ps.py @@ -7,23 +7,23 @@ import logging import salt.utils.beacons try: - import salt.utils.psutil_compat as psutil + import psutil HAS_PSUTIL = True except ImportError: HAS_PSUTIL = False - -log = logging.getLogger(__name__) # pylint: disable=invalid-name +log = logging.getLogger(__name__) __virtualname__ = "ps" def __virtual__(): if not HAS_PSUTIL: - err_msg = "psutil library is missing." - log.error("Unable to load %s beacon: %s", __virtualname__, err_msg) - return False, err_msg + return ( + False, + f"Unable to load {__virtualname__} beacon: psutil library not installed", + ) return __virtualname__ diff --git a/salt/channel/client.py b/salt/channel/client.py index f49ec473f85..cb85ce024e2 100644 --- a/salt/channel/client.py +++ b/salt/channel/client.py @@ -226,7 +226,7 @@ class AsyncReqChannel: if HAS_M2: aes = key.private_decrypt(ret["key"], RSA.pkcs1_oaep_padding) else: - cipher = PKCS1_OAEP.new(key) + cipher = PKCS1_OAEP.new(key) # pylint: disable=used-before-assignment aes = cipher.decrypt(ret["key"]) # Decrypt using the public key. diff --git a/salt/channel/server.py b/salt/channel/server.py index 9be0178342a..530088548ef 100644 --- a/salt/channel/server.py +++ b/salt/channel/server.py @@ -621,7 +621,7 @@ class ReqServerChannel: return {"enc": "clear", "load": {"ret": False}} if not HAS_M2: - cipher = PKCS1_OAEP.new(pub) + cipher = PKCS1_OAEP.new(pub) # pylint: disable=used-before-assignment ret = { "enc": "pub", "pub_key": self.master_key.get_pub_str(), diff --git a/salt/cli/batch.py b/salt/cli/batch.py index 85250c02efd..2e43b0ee22b 100644 --- a/salt/cli/batch.py +++ b/salt/cli/batch.py @@ -90,7 +90,10 @@ class Batch: """ Return the active number of minions to maintain """ - partition = lambda x: float(x) / 100.0 * len(self.minions) + + def partition(x): + return float(x) / 100.0 * len(self.minions) + try: if isinstance(self.opts["batch"], str) and "%" in self.opts["batch"]: res = partition(float(self.opts["batch"].strip("%"))) diff --git a/salt/cli/cp.py b/salt/cli/cp.py index 39ba429134d..42ebfd9d515 100644 --- a/salt/cli/cp.py +++ b/salt/cli/cp.py @@ -259,13 +259,7 @@ class SaltCP: log.debug( "Creating empty dir %s on %starget '%s'", dirname, - ( - "{} ".format( - selected_target_option - ) # pylint: disable=str-format-in-logging - if selected_target_option - else "" - ), + f"{selected_target_option} " if selected_target_option else "", tgt, ) args = [tgt, "cp.recv_chunked", [remote_path, None], timeout] diff --git a/salt/client/__init__.py b/salt/client/__init__.py index 3be1150b111..5f5d0b24c0d 100644 --- a/salt/client/__init__.py +++ b/salt/client/__init__.py @@ -1294,7 +1294,7 @@ class LocalClient: except KeyError as exc: # This is a safe pass. We're just using the try/except to # avoid having to deep-check for keys. - missing_key = exc.__str__().strip("'\"") + missing_key = str(exc).strip("'\"") if missing_key == "retcode": log.debug("retcode missing from client return") else: diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py index ae51bdb4d8c..b8cf40f0f51 100644 --- a/salt/client/ssh/__init__.py +++ b/salt/client/ssh/__init__.py @@ -3,7 +3,6 @@ Create ssh executor system """ import base64 -import binascii import copy import datetime import getpass @@ -527,7 +526,7 @@ class SSH(MultiprocessingStateMixin): try: retcode = int(retcode) except (TypeError, ValueError): - log.warning(f"Got an invalid retcode for host '{host}': '{retcode}'") + log.warning("Got an invalid retcode for host '%s': '%s'", host, retcode) retcode = 1 try: ret = ( @@ -549,7 +548,8 @@ class SSH(MultiprocessingStateMixin): ret.pop("_error", None) except Exception as err: # pylint: disable=broad-except log.error( - f"Error while parsing the command output: {err}", + "Error while parsing the command output: %s", + err, exc_info_on_loglevel=logging.DEBUG, ) ret = { @@ -589,7 +589,7 @@ class SSH(MultiprocessingStateMixin): try: retcode = int(retcode) except (TypeError, ValueError): - log.warning(f"Got an invalid retcode for host '{host}': '{retcode}'") + log.warning("Got an invalid retcode for host '%s': '%s'", host, retcode) retcode = 1 ret["ret"] = salt.client.ssh.wrapper.parse_ret(stdout, stderr, retcode) except ( @@ -608,7 +608,8 @@ class SSH(MultiprocessingStateMixin): ret["ret"].pop("_error", None) except Exception as err: # pylint: disable=broad-except log.error( - f"Error while parsing the command output: {err}", + "Error while parsing the command output: %s", + err, exc_info_on_loglevel=logging.DEBUG, ) ret["ret"] = { @@ -628,7 +629,7 @@ class SSH(MultiprocessingStateMixin): """ que = multiprocessing.Queue() running = {} - target_iter = self.targets.__iter__() + target_iter = iter(self.targets) returned = set() rets = set() init = False @@ -869,7 +870,7 @@ class SSH(MultiprocessingStateMixin): for ret, retcode in self.handle_ssh(): host = next(iter(ret)) if not isinstance(retcode, int): - log.warning(f"Host '{host}' returned an invalid retcode: {retcode}") + log.warning("Host '%s' returned an invalid retcode: %s", host, retcode) retcode = 1 final_exit = max(final_exit, retcode) @@ -880,7 +881,9 @@ class SSH(MultiprocessingStateMixin): retcode = int(deploy_retcode) except (TypeError, ValueError): log.warning( - f"Got an invalid deploy retcode for host '{host}': '{retcode}'" + "Got an invalid deploy retcode for host '%s': '%s'", + host, + retcode, ) retcode = 1 final_exit = max(final_exit, retcode) @@ -1388,7 +1391,8 @@ class Single: ) except (TypeError, ValueError): log.warning( - f"Wrapper module set invalid value for retcode: '{self.context['retcode']}" + "Wrapper module set invalid value for retcode: %s", + self.context["retcode"], ) retcode = max(retcode, 1) @@ -1860,7 +1864,7 @@ def ssh_version(): ["ssh", "-V"], stdout=subprocess.PIPE, stderr=subprocess.PIPE ).communicate() try: - version_parts = ret[1].split(b",")[0].split(b"_")[1] + version_parts = ret[1].split(b",", maxsplit=1)[0].split(b"_")[1] parts = [] for part in version_parts: try: diff --git a/salt/client/ssh/shell.py b/salt/client/ssh/shell.py index 74d70f7f39b..9846f8ce01c 100644 --- a/salt/client/ssh/shell.py +++ b/salt/client/ssh/shell.py @@ -342,7 +342,7 @@ class Shell: pardir = os.path.dirname(remote) if not pardir: log.warning( - f"Makedirs called on relative filename: '{remote}'. Skipping." + "Makedirs called on relative filename: '%s'. Skipping.", remote ) else: ret = self.exec_cmd("mkdir -p " + shlex.quote(pardir)) diff --git a/salt/client/ssh/ssh_py_shim.py b/salt/client/ssh/ssh_py_shim.py index 24e4c0cc9cb..679fb52cbbb 100644 --- a/salt/client/ssh/ssh_py_shim.py +++ b/salt/client/ssh/ssh_py_shim.py @@ -41,7 +41,6 @@ ARGS = None # The below line is where OPTIONS can be redefined with internal options # (rather than cli arguments) when the shim is bundled by # client.ssh.Single._cmd_str() -# pylint: disable=block-comment-should-start-with-cardinal-space #%%OPTS @@ -230,7 +229,9 @@ def get_executable(): Find executable which matches supported python version in the thin """ pymap = {} - with open(os.path.join(OPTIONS.saltdir, "supported-versions")) as _fp: + with open( + os.path.join(OPTIONS.saltdir, "supported-versions"), encoding="utf-8" + ) as _fp: for line in _fp.readlines(): ns, v_maj, v_min = line.strip().split(":") pymap[ns] = (int(v_maj), int(v_min)) @@ -314,7 +315,7 @@ def main(argv): # pylint: disable=W0613 ) ) need_deployment() - with open(code_checksum_path, "r") as vpo: + with open(code_checksum_path, "r", encoding="utf-8") as vpo: cur_code_cs = vpo.readline().strip() if cur_code_cs != OPTIONS.code_checksum: sys.stderr.write( @@ -330,7 +331,7 @@ def main(argv): # pylint: disable=W0613 sys.stderr.write('ERROR: thin is missing "{0}"\n'.format(salt_call_path)) need_deployment() - with open(os.path.join(OPTIONS.saltdir, "minion"), "w") as config: + with open(os.path.join(OPTIONS.saltdir, "minion"), "w", encoding="utf-8") as config: config.write(OPTIONS.config + "\n") if OPTIONS.ext_mods: ext_path = os.path.join(OPTIONS.saltdir, EXT_ARCHIVE) @@ -340,7 +341,7 @@ def main(argv): # pylint: disable=W0613 version_path = os.path.join(OPTIONS.saltdir, "ext_version") if not os.path.exists(version_path) or not os.path.isfile(version_path): need_ext() - with open(version_path, "r") as vpo: + with open(version_path, "r", encoding="utf-8") as vpo: cur_version = vpo.readline().strip() if cur_version != OPTIONS.ext_mods: need_ext() diff --git a/salt/client/ssh/wrapper/grains.py b/salt/client/ssh/wrapper/grains.py index 2483726ae21..70d2c7e72da 100644 --- a/salt/client/ssh/wrapper/grains.py +++ b/salt/client/ssh/wrapper/grains.py @@ -22,21 +22,28 @@ def _serial_sanitizer(instr): return "{}{}".format(instr[:index], "X" * (length - index)) -_FQDN_SANITIZER = lambda x: "MINION.DOMAINNAME" -_HOSTNAME_SANITIZER = lambda x: "MINION" -_DOMAINNAME_SANITIZER = lambda x: "DOMAINNAME" +def _fqdn_sanitizer(x): + return "MINION.DOMAINNAME" + + +def _hostname_sanitizer(x): + return "MINION" + + +def _domainname_sanitizer(x): + return "DOMAINNAME" # A dictionary of grain -> function mappings for sanitizing grain output. This # is used when the 'sanitize' flag is given. _SANITIZERS = { "serialnumber": _serial_sanitizer, - "domain": _DOMAINNAME_SANITIZER, - "fqdn": _FQDN_SANITIZER, - "id": _FQDN_SANITIZER, - "host": _HOSTNAME_SANITIZER, - "localhost": _HOSTNAME_SANITIZER, - "nodename": _HOSTNAME_SANITIZER, + "domain": _domainname_sanitizer, + "fqdn": _fqdn_sanitizer, + "id": _fqdn_sanitizer, + "host": _hostname_sanitizer, + "localhost": _hostname_sanitizer, + "nodename": _hostname_sanitizer, } diff --git a/salt/client/ssh/wrapper/pillar.py b/salt/client/ssh/wrapper/pillar.py index bc1b625d5cb..f085771614c 100644 --- a/salt/client/ssh/wrapper/pillar.py +++ b/salt/client/ssh/wrapper/pillar.py @@ -12,7 +12,9 @@ try: from collections.abc import Mapping except ImportError: # We still allow Py2 import because this could be executed in a machine with Py2. - from collections import Mapping # pylint: disable=no-name-in-module + from collections import ( # pylint: disable=no-name-in-module,deprecated-class + Mapping, + ) def get(key, default="", merge=False, delimiter=DEFAULT_TARGET_DELIM): diff --git a/salt/cloud/cli.py b/salt/cloud/cli.py index 4a441a0798c..19b26e42287 100644 --- a/salt/cloud/cli.py +++ b/salt/cloud/cli.py @@ -390,12 +390,10 @@ class SaltCloud(salt.utils.parsers.SaltCloudParser): self.error(msg.format(exc)) # This is a generic exception, log it, include traceback if # debug logging is enabled and exit. - # pylint: disable=str-format-in-logging log.error( msg.format(exc), # Show the traceback if the debug logging level is # enabled exc_info_on_loglevel=logging.DEBUG, ) - # pylint: enable=str-format-in-logging self.exit(salt.defaults.exitcodes.EX_GENERIC) diff --git a/salt/cloud/clouds/aliyun.py b/salt/cloud/clouds/aliyun.py index 9879e4df223..f7109ec8754 100644 --- a/salt/cloud/clouds/aliyun.py +++ b/salt/cloud/clouds/aliyun.py @@ -794,7 +794,7 @@ def query(params=None): signature = _compute_signature(parameters, access_key_secret) parameters["Signature"] = signature - request = requests.get(path, params=parameters, verify=True) + request = requests.get(path, params=parameters, verify=True, timeout=120) if request.status_code != 200: raise SaltCloudSystemExit( "An error occurred while querying aliyun ECS. HTTP Code: {} " diff --git a/salt/cloud/clouds/clc.py b/salt/cloud/clouds/clc.py index dc635a8ccde..b7d8cbd3a4a 100644 --- a/salt/cloud/clouds/clc.py +++ b/salt/cloud/clouds/clc.py @@ -308,7 +308,7 @@ def get_build_status(req_id, nodename): counter = 0 req_id = str(req_id) while counter < 10: - queue = clc.v1.Blueprint.GetStatus(request_id=(req_id)) + queue = clc.v1.Blueprint.GetStatus(request_id=req_id) if queue["PercentComplete"] == 100: server_name = queue["Servers"][0] creds = get_creds() diff --git a/salt/cloud/clouds/digitalocean.py b/salt/cloud/clouds/digitalocean.py index 487179f6de0..5ef14b67d12 100644 --- a/salt/cloud/clouds/digitalocean.py +++ b/salt/cloud/clouds/digitalocean.py @@ -483,9 +483,14 @@ def create(vm_): dns_hostname, dns_domain, ) - __add_dns_addr__ = lambda t, d: post_dns_record( - dns_domain=dns_domain, name=dns_hostname, record_type=t, record_data=d - ) + + def __add_dns_addr__(t, d): + return post_dns_record( + dns_domain=dns_domain, + name=dns_hostname, + record_type=t, + record_data=d, + ) log.debug("create_dns_record: %s", __add_dns_addr__) else: @@ -651,6 +656,7 @@ def query( "Authorization": "Bearer " + personal_access_token, "Content-Type": "application/json", }, + timeout=120, ) if request.status_code > 299: raise SaltCloudSystemExit( diff --git a/salt/cloud/clouds/ec2.py b/salt/cloud/clouds/ec2.py index 11f6dd6a926..91e9eddd6b2 100644 --- a/salt/cloud/clouds/ec2.py +++ b/salt/cloud/clouds/ec2.py @@ -401,7 +401,7 @@ def query( log.trace("EC2 Request Parameters: %s", params_with_headers) try: result = requests.get( - requesturl, headers=headers, params=params_with_headers + requesturl, headers=headers, params=params_with_headers, timeout=120 ) log.debug( "EC2 Response Status Code: %s", @@ -1195,10 +1195,11 @@ def get_imageid(vm_): "Filter.0.Name": "name", "Filter.0.Value.0": image, } + # Query AWS, sort by 'creationDate' and get the last imageId - _t = lambda x: datetime.datetime.strptime( - x["creationDate"], "%Y-%m-%dT%H:%M:%S.%fZ" - ) + def _t(x): + return datetime.datetime.strptime(x["creationDate"], "%Y-%m-%dT%H:%M:%S.%fZ") + image_id = sorted( aws.query( params, diff --git a/salt/cloud/clouds/joyent.py b/salt/cloud/clouds/joyent.py index 6326d202b58..403e2ffab92 100644 --- a/salt/cloud/clouds/joyent.py +++ b/salt/cloud/clouds/joyent.py @@ -1163,8 +1163,8 @@ def query(action=None, command=None, args=None, method="GET", location=None, dat digest = md.final() signed = rsa_key.sign(digest, algo="sha256") else: - rsa_ = PKCS1_v1_5.new(rsa_key) - hash_ = SHA256.new() + rsa_ = PKCS1_v1_5.new(rsa_key) # pylint: disable=used-before-assignment + hash_ = SHA256.new() # pylint: disable=used-before-assignment hash_.update(timestamp.encode(__salt_system_encoding__)) signed = rsa_.sign(hash_) signed = base64.b64encode(signed) diff --git a/salt/cloud/clouds/linode.py b/salt/cloud/clouds/linode.py index 88461b94616..616ef18a21c 100644 --- a/salt/cloud/clouds/linode.py +++ b/salt/cloud/clouds/linode.py @@ -452,7 +452,9 @@ class LinodeAPIv4(LinodeAPI): attempt = 0 while True: try: - result = requests.request(method, url, json=data, headers=headers) + result = requests.request( + method, url, json=data, headers=headers, timeout=120 + ) log.debug("Linode API response status code: %d", result.status_code) log.trace("Linode API response body: %s", result.text) @@ -1018,7 +1020,9 @@ class LinodeAPIv4(LinodeAPI): "entity.type": entity, } last_event = None - condition = lambda event: self._check_event_status(event, status) + + def condition(event): + return self._check_event_status(event, status) while True: if last_event is not None: diff --git a/salt/cloud/clouds/proxmox.py b/salt/cloud/clouds/proxmox.py index a3152a9cd71..21b0a485c6d 100644 --- a/salt/cloud/clouds/proxmox.py +++ b/salt/cloud/clouds/proxmox.py @@ -148,7 +148,9 @@ def _authenticate(): connect_data = {"username": username, "password": passwd} full_url = f"https://{url}:{port}/api2/json/access/ticket" - response = requests.post(full_url, verify=verify_ssl, data=connect_data) + response = requests.post( + full_url, verify=verify_ssl, data=connect_data, timeout=120 + ) response.raise_for_status() returned_data = response.json() @@ -182,6 +184,7 @@ def query(conn_type, option, post_data=None): data=post_data, cookies=ticket, headers=httpheaders, + timeout=120, ) elif conn_type == "put": httpheaders["CSRFPreventionToken"] = csrf @@ -191,6 +194,7 @@ def query(conn_type, option, post_data=None): data=post_data, cookies=ticket, headers=httpheaders, + timeout=120, ) elif conn_type == "delete": httpheaders["CSRFPreventionToken"] = csrf @@ -200,9 +204,12 @@ def query(conn_type, option, post_data=None): data=post_data, cookies=ticket, headers=httpheaders, + timeout=120, ) elif conn_type == "get": - response = requests.get(full_url, verify=verify_ssl, cookies=ticket) + response = requests.get( + full_url, verify=verify_ssl, cookies=ticket, timeout=120 + ) try: response.raise_for_status() @@ -871,7 +878,7 @@ def _import_api(): """ global api full_url = f"https://{url}:{port}/pve-docs/api-viewer/apidoc.js" - returned_data = requests.get(full_url, verify=verify_ssl) + returned_data = requests.get(full_url, verify=verify_ssl, timeout=120) re_filter = re.compile(" (?:pveapi|apiSchema) = (.*)^;", re.DOTALL | re.MULTILINE) api_json = re_filter.findall(returned_data.text)[0] diff --git a/salt/cloud/clouds/qingcloud.py b/salt/cloud/clouds/qingcloud.py index 5cfa8a19930..6c3bda925e4 100644 --- a/salt/cloud/clouds/qingcloud.py +++ b/salt/cloud/clouds/qingcloud.py @@ -179,7 +179,7 @@ def query(params=None): # print('parameters:') # pprint.pprint(real_parameters) - request = requests.get(path, params=real_parameters, verify=verify_ssl) + request = requests.get(path, params=real_parameters, verify=verify_ssl, timeout=120) # print('url:') # print(request.url) @@ -437,7 +437,7 @@ def _get_size(vm_): if not vm_size: raise SaltCloudNotFound("No size specified for this instance.") - if vm_size in sizes.keys(): + if vm_size in sizes: return vm_size raise SaltCloudNotFound(f"The specified size, '{vm_size}', could not be found.") diff --git a/salt/cloud/clouds/vmware.py b/salt/cloud/clouds/vmware.py index 2a9c0563b87..91b1f1b3d25 100644 --- a/salt/cloud/clouds/vmware.py +++ b/salt/cloud/clouds/vmware.py @@ -1646,7 +1646,7 @@ def _get_snapshots(snapshot_list, current_snapshot=None, parent_snapshot_path="" snapshots[snapshot_path] = { "name": snapshot.name, "description": snapshot.description, - "created": str(snapshot.createTime).split(".")[0], + "created": str(snapshot.createTime).split(".", maxsplit=1)[0], "state": snapshot.state, "path": snapshot_path, } diff --git a/salt/config/__init__.py b/salt/config/__init__.py index edc4cc6b5b2..c0038f1eda6 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -41,8 +41,6 @@ from salt._logging import ( try: import psutil - if not hasattr(psutil, "virtual_memory"): - raise ImportError("Version of psutil too old.") HAS_PSUTIL = True except ImportError: HAS_PSUTIL = False @@ -89,7 +87,7 @@ def _gather_buffer_space(): Result is in bytes. """ - if HAS_PSUTIL and psutil.version_info >= (0, 6, 0): + if HAS_PSUTIL: # Oh good, we have psutil. This will be quick. total_mem = psutil.virtual_memory().total else: diff --git a/salt/config/schemas/common.py b/salt/config/schemas/common.py index 5c32ecf789a..d0ba546883d 100644 --- a/salt/config/schemas/common.py +++ b/salt/config/schemas/common.py @@ -46,7 +46,7 @@ class MinionDefaultInclude(DefaultIncludeConfig): class MasterDefaultInclude(DefaultIncludeConfig): __target__ = "master" - __confd_directory = "master.d" + __confd_directory = "master.d" # pylint: disable=unused-private-member class IncludeConfig(Schema): diff --git a/salt/engines/slack.py b/salt/engines/slack.py index cf8bef74d13..0d331668904 100644 --- a/salt/engines/slack.py +++ b/salt/engines/slack.py @@ -889,8 +889,6 @@ class SlackClient: if cmd in runner_functions: runner = salt.runner.RunnerClient(__opts__) log.debug("Command %s will run via runner_functions", cmd) - # pylint is tripping - # pylint: disable=missing-whitespace-after-comma job_id_dict = runner.asynchronous(cmd, {"arg": args, "kwarg": kwargs}) job_id = job_id_dict["jid"] diff --git a/salt/engines/slack_bolt_engine.py b/salt/engines/slack_bolt_engine.py index 954ef79f556..7cd82ff877f 100644 --- a/salt/engines/slack_bolt_engine.py +++ b/salt/engines/slack_bolt_engine.py @@ -994,8 +994,6 @@ class SlackClient: if cmd in runner_functions: runner = salt.runner.RunnerClient(__opts__) log.debug("Command %s will run via runner_functions", cmd) - # pylint is tripping - # pylint: disable=missing-whitespace-after-comma job_id_dict = runner.asynchronous(cmd, {"arg": args, "kwarg": kwargs}) job_id = job_id_dict["jid"] diff --git a/salt/ext/backports_abc.py b/salt/ext/backports_abc.py index da4cb329832..64669416f3e 100644 --- a/salt/ext/backports_abc.py +++ b/salt/ext/backports_abc.py @@ -87,7 +87,7 @@ def mk_gen(): return True return NotImplemented - generator = type((lambda: (yield))()) + generator = type((lambda: (yield))()) # pylint: disable=unnecessary-direct-lambda-call Generator.register(generator) return Generator diff --git a/salt/ext/ipaddress.py b/salt/ext/ipaddress.py index 9ce8ba83d88..f1ee6bcaf38 100644 --- a/salt/ext/ipaddress.py +++ b/salt/ext/ipaddress.py @@ -2162,8 +2162,7 @@ class IPv6Interface(IPv6Address): return x def __str__(self): - return '%s/%d' % (super().__str__(), - self._prefixlen) + return '%s/%d' % (super(), self._prefixlen) def __eq__(self, other): address_equal = IPv6Address.__eq__(self, other) diff --git a/salt/fileserver/s3fs.py b/salt/fileserver/s3fs.py index 520c3d53635..01f527b1984 100644 --- a/salt/fileserver/s3fs.py +++ b/salt/fileserver/s3fs.py @@ -725,7 +725,7 @@ def _get_file_from_s3(metadata, saltenv, bucket_name, path, cached_file_path): if cached_md5 == file_md5: return else: - log.info(f"found different hash for file {path}, updating...") + log.info("found different hash for file %s, updating...", path) else: cached_file_stat = os.stat(cached_file_path) cached_file_size = cached_file_stat.st_size @@ -761,6 +761,7 @@ def _get_file_from_s3(metadata, saltenv, bucket_name, path, cached_file_path): https_enable=https_enable, ) if ret is not None: + s3_file_mtime = s3_file_size = None for header_name, header_value in ret["headers"].items(): name = header_name.strip() value = header_value.strip() @@ -770,9 +771,8 @@ def _get_file_from_s3(metadata, saltenv, bucket_name, path, cached_file_path): ) elif str(name).lower() == "content-length": s3_file_size = int(value) - if ( - cached_file_size == s3_file_size - and cached_file_mtime > s3_file_mtime + if (s3_file_size and cached_file_size == s3_file_size) and ( + s3_file_mtime and cached_file_mtime > s3_file_mtime ): log.info( "%s - %s : %s skipped download since cached file size " diff --git a/salt/grains/core.py b/salt/grains/core.py index 728a5b1494a..08e86724186 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -2903,8 +2903,8 @@ def ip_fqdn(): if not ret["ipv" + ipv_num]: ret[key] = [] else: + start_time = datetime.datetime.utcnow() try: - start_time = datetime.datetime.utcnow() info = socket.getaddrinfo(_fqdn, None, socket_type) ret[key] = list({item[4][0] for item in info}) except (OSError, UnicodeError): diff --git a/salt/loader/lazy.py b/salt/loader/lazy.py index 3e6ad9ffa7c..4afba4b5721 100644 --- a/salt/loader/lazy.py +++ b/salt/loader/lazy.py @@ -15,7 +15,7 @@ import time import traceback import types from collections.abc import MutableMapping -from zipimport import zipimporter +from zipimport import zipimporter # pylint: disable=no-name-in-module import salt.config import salt.defaults.events diff --git a/salt/master.py b/salt/master.py index 516bdd5bf84..77fe46a255e 100644 --- a/salt/master.py +++ b/salt/master.py @@ -196,7 +196,7 @@ class SMaster: if event: event.fire_event( - {f"rotate_cluster_aes_key": True}, tag="rotate_cluster_aes_key" + {"rotate_cluster_aes_key": True}, tag="rotate_cluster_aes_key" ) if publisher: @@ -868,7 +868,9 @@ class Master(SMaster): mod = ".".join(proc.split(".")[:-1]) cls = proc.split(".")[-1] _tmp = __import__(mod, globals(), locals(), [cls], -1) - cls = _tmp.__getattribute__(cls) + cls = _tmp.__getattribute__( # pylint: disable=unnecessary-dunder-call + cls + ) name = f"ExtProcess({cls.__qualname__})" self.process_manager.add_process(cls, args=(self.opts,), name=name) except Exception: # pylint: disable=broad-except diff --git a/salt/minion.py b/salt/minion.py index 4246bdfdee8..e05d9c7a956 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -81,21 +81,19 @@ from salt.utils.odict import OrderedDict from salt.utils.process import ProcessManager, SignalHandlingProcess, default_signals from salt.utils.zeromq import ZMQ_VERSION_INFO, zmq -HAS_PSUTIL = False try: - import salt.utils.psutil_compat as psutil + import psutil HAS_PSUTIL = True except ImportError: - pass + HAS_PSUTIL = False -HAS_RESOURCE = False try: import resource HAS_RESOURCE = True except ImportError: - pass + HAS_RESOURCE = False try: import salt.utils.win_functions @@ -3695,8 +3693,11 @@ class SyndicManager(MinionBase): self.raw_events = [] def reconnect_event_bus(self, something): + # XXX: set_event_handler does not return anything! + # pylint: disable=assignment-from-no-return future = self.local.event.set_event_handler(self._process_event) self.io_loop.add_future(future, self.reconnect_event_bus) + # pylint: enable=assignment-from-no-return # Syndic Tune In def tune_in(self): @@ -3716,8 +3717,12 @@ class SyndicManager(MinionBase): self.job_rets = {} self.raw_events = [] self._reset_event_aggregation() + + # XXX: set_event_handler does not return anything! + # pylint: disable=assignment-from-no-return future = self.local.event.set_event_handler(self._process_event) self.io_loop.add_future(future, self.reconnect_event_bus) + # pylint: enable=assignment-from-no-return # forward events every syndic_event_forward_timeout self.forward_events = tornado.ioloop.PeriodicCallback( diff --git a/salt/modules/acme.py b/salt/modules/acme.py index 493b95a4c9c..659b3ce8183 100644 --- a/salt/modules/acme.py +++ b/salt/modules/acme.py @@ -216,7 +216,7 @@ def cert( cmd.append("--authenticator webroot") if webroot is not True: cmd.append(f"--webroot-path {webroot}") - elif dns_plugin: + elif dns_plugin in supported_dns_plugins: if dns_plugin == "cloudflare": cmd.append("--dns-cloudflare") cmd.append(f"--dns-cloudflare-credentials {dns_plugin_credentials}") diff --git a/salt/modules/aptpkg.py b/salt/modules/aptpkg.py index 6cddea418bc..ff5991c11c1 100644 --- a/salt/modules/aptpkg.py +++ b/salt/modules/aptpkg.py @@ -239,7 +239,7 @@ if not HAS_APT: opts = _get_opts(self.line) self.architectures.extend(opts["arch"]["value"]) self.signedby = opts["signedby"]["value"] - for opt in opts.keys(): + for opt in opts: opt = opts[opt]["full"] if opt: try: @@ -1620,9 +1620,11 @@ def _get_upgradable(dist_upgrade=True, **kwargs): # rexp parses lines that look like the following: # Conf libxfont1 (1:1.4.5-1 Debian:testing [i386]) - rexp = re.compile("(?m)^Conf " "([^ ]+) " r"\(([^ ]+)") # Package name # Version + rexp = re.compile(r"(?m)^Conf ([^ ]+) \(([^ ]+)") # Package name # Version keys = ["name", "version"] - _get = lambda l, k: l[keys.index(k)] + + def _get(line, k): + return line[keys.index(k)] upgrades = rexp.findall(out) @@ -1696,7 +1698,10 @@ def version_cmp(pkg1, pkg2, ignore_epoch=False, **kwargs): salt '*' pkg.version_cmp '0.2.4-0ubuntu1' '0.2.4.1-0ubuntu1' """ - normalize = lambda x: str(x).split(":", 1)[-1] if ignore_epoch else str(x) + + def normalize(x): + return str(x).split(":", 1)[-1] if ignore_epoch else str(x) + # both apt_pkg.version_compare and _cmd_quote need string arguments. pkg1 = normalize(pkg1) pkg2 = normalize(pkg2) diff --git a/salt/modules/archive.py b/salt/modules/archive.py index f96d03bc404..9651cc406d8 100644 --- a/salt/modules/archive.py +++ b/salt/modules/archive.py @@ -379,9 +379,7 @@ def list_( try: dirs, files, links = func(name, cached, *args) except OSError as exc: - raise CommandExecutionError( - f"Failed to list contents of {name}: {exc.__str__()}" - ) + raise CommandExecutionError(f"Failed to list contents of {name}: {exc}") except CommandExecutionError as exc: raise except Exception as exc: # pylint: disable=broad-except @@ -395,9 +393,7 @@ def list_( log.debug("Cleaned cached archive %s", cached) except OSError as exc: if exc.errno != errno.ENOENT: - log.warning( - "Failed to clean cached archive %s: %s", cached, exc.__str__() - ) + log.warning("Failed to clean cached archive %s: %s", cached, exc) if strip_components: for item in (dirs, files, links): @@ -796,8 +792,8 @@ def zip_(zip_file, sources, template=None, cwd=None, runas=None, zip64=False): os.setegid(uinfo["gid"]) os.seteuid(uinfo["uid"]) + exc = None try: - exc = None archived_files = [] with contextlib.closing( zipfile.ZipFile(zip_file, "w", zipfile.ZIP_DEFLATED, zip64) @@ -1199,7 +1195,7 @@ def is_encrypted(name, clean=False, saltenv="base", source_hash=None, use_etag=F except zipfile.BadZipfile: raise CommandExecutionError(f"{name} is not a ZIP file", info=archive_info) except Exception as exc: # pylint: disable=broad-except - raise CommandExecutionError(exc.__str__(), info=archive_info) + raise CommandExecutionError(exc, info=archive_info) else: ret = False @@ -1209,9 +1205,7 @@ def is_encrypted(name, clean=False, saltenv="base", source_hash=None, use_etag=F log.debug("Cleaned cached archive %s", cached) except OSError as exc: if exc.errno != errno.ENOENT: - log.warning( - "Failed to clean cached archive %s: %s", cached, exc.__str__() - ) + log.warning("Failed to clean cached archive %s: %s", cached, exc) return ret diff --git a/salt/modules/boto3_route53.py b/salt/modules/boto3_route53.py index 5a0f730e018..8183de2f5db 100644 --- a/salt/modules/boto3_route53.py +++ b/salt/modules/boto3_route53.py @@ -948,7 +948,7 @@ def _aws_decode(x): if "\\" in x: return x.decode("unicode_escape") - if type(x) == bytes: + if isinstance(x, bytes): return x.decode("idna") return x diff --git a/salt/modules/boto3_sns.py b/salt/modules/boto3_sns.py index 197cd795e24..825c9b23bb0 100644 --- a/salt/modules/boto3_sns.py +++ b/salt/modules/boto3_sns.py @@ -138,7 +138,7 @@ def topic_exists(name, region=None, key=None, keyid=None, profile=None): salt myminion boto3_sns.topic_exists mytopic region=us-east-1 """ topics = list_topics(region=region, key=key, keyid=keyid, profile=profile) - return name in list(topics.values() + topics.keys()) + return name in list(topics.values()) + list(topics) def create_topic(Name, region=None, key=None, keyid=None, profile=None): diff --git a/salt/modules/btrfs.py b/salt/modules/btrfs.py index 30f857de5d7..e2e7328a9bf 100644 --- a/salt/modules/btrfs.py +++ b/salt/modules/btrfs.py @@ -221,7 +221,10 @@ def _usage_specific(raw): """ Parse usage/specific. """ - get_key = lambda val: dict([tuple(val.split(":"))]) + + def get_key(val): + return dict([tuple(val.split(":"))]) + raw = raw.split("\n") section, size, used = raw[0].split(" ") section = section.replace(",", "_").replace(":", "").lower() diff --git a/salt/modules/consul.py b/salt/modules/consul.py index d1eca824b64..a457569eb82 100644 --- a/salt/modules/consul.py +++ b/salt/modules/consul.py @@ -75,7 +75,7 @@ def _query( data = None else: if data is not None: - if type(data) != str: + if not isinstance(data, str): data = salt.utils.json.dumps(data) else: data = salt.utils.json.dumps({}) diff --git a/salt/modules/cp.py b/salt/modules/cp.py index 346de51b1e3..b698398d42e 100644 --- a/salt/modules/cp.py +++ b/salt/modules/cp.py @@ -116,7 +116,7 @@ def recv_chunked(dest, chunk, append=False, compressed=True, mode=None): if os.path.isfile(dest): return "Path exists and is a file" else: - return _error(exc.__str__()) + return _error(str(exc)) return True chunk = base64.b64decode(chunk) @@ -127,12 +127,12 @@ def recv_chunked(dest, chunk, append=False, compressed=True, mode=None): except OSError as exc: if exc.errno != errno.ENOENT: # Parent dir does not exist, we need to create it - return _error(exc.__str__()) + return _error(str(exc)) try: os.makedirs(os.path.dirname(dest)) except OSError as makedirs_exc: # Failed to make directory - return _error(makedirs_exc.__str__()) + return _error(str(makedirs_exc)) fh_ = salt.utils.files.fopen(dest, open_mode) # pylint: disable=W8470 try: @@ -140,7 +140,7 @@ def recv_chunked(dest, chunk, append=False, compressed=True, mode=None): fh_.write(salt.utils.gzip_util.uncompress(chunk) if compressed else chunk) except OSError as exc: # Write failed - return _error(exc.__str__()) + return _error(str(exc)) else: # Write successful if not append and mode is not None: @@ -150,7 +150,7 @@ def recv_chunked(dest, chunk, append=False, compressed=True, mode=None): try: os.chmod(dest, mode) except OSError as exc: - return _error(exc.__str__()) + return _error(str(exc)) return True finally: try: diff --git a/salt/modules/cryptdev.py b/salt/modules/cryptdev.py index 015272135a5..77e84683aec 100644 --- a/salt/modules/cryptdev.py +++ b/salt/modules/cryptdev.py @@ -263,7 +263,10 @@ def set_crypttab( criteria = entry.pick(match_on) except KeyError: - filterFn = lambda key: key not in _crypttab_entry.crypttab_keys + + def filterFn(key): + return key not in _crypttab_entry.crypttab_keys + invalid_keys = filter(filterFn, match_on) msg = f'Unrecognized keys in match_on: "{invalid_keys}"' diff --git a/salt/modules/csf.py b/salt/modules/csf.py index b3d669547ce..0f7a27c365a 100644 --- a/salt/modules/csf.py +++ b/salt/modules/csf.py @@ -29,7 +29,7 @@ def _temp_exists(method, ip): """ _type = method.replace("temp", "").upper() cmd = ( - "csf -t | awk -v code=1 -v type=_type -v ip=ip '$1==type && $2==ip {{code=0}}" + "csf -t | awk -v code=1 -v type={_type} -v ip={ip} '$1==type && $2==ip {{code=0}}" " END {{exit code}}'".format(_type=_type, ip=ip) ) exists = __salt__["cmd.run_all"](cmd) diff --git a/salt/modules/datadog_api.py b/salt/modules/datadog_api.py index 74ba7de0e29..ad775ef00dc 100644 --- a/salt/modules/datadog_api.py +++ b/salt/modules/datadog_api.py @@ -157,7 +157,9 @@ def cancel_downtime(api_key=None, app_key=None, scope=None, id=None): elif scope: params = {"api_key": api_key, "application_key": app_key, "scope": scope} response = requests.post( - "https://app.datadoghq.com/api/v1/downtime/cancel/by_scope", params=params + "https://app.datadoghq.com/api/v1/downtime/cancel/by_scope", + params=params, + timeout=120, ) if response.status_code == 200: ret["result"] = True diff --git a/salt/modules/dig.py b/salt/modules/dig.py index 1cd7ad37e33..79023236653 100644 --- a/salt/modules/dig.py +++ b/salt/modules/dig.py @@ -314,7 +314,7 @@ def MX(domain, resolve=False, nameserver=None): stdout = [x.split() for x in cmd["stdout"].split("\n")] if resolve: - return [(lambda x: [x[0], A(x[1], nameserver)[0]])(x) for x in stdout] + return [[x[0], A(x[1], nameserver)[0]] for x in stdout] return stdout diff --git a/salt/modules/disk.py b/salt/modules/disk.py index 9f03c2b9992..5dbd77000f3 100644 --- a/salt/modules/disk.py +++ b/salt/modules/disk.py @@ -49,7 +49,7 @@ def _parse_numbers(text): "Z": "10E21", "Y": "10E24", } - if text[-1] in postPrefixes.keys(): + if text[-1] in postPrefixes: v = decimal.Decimal(text[:-1]) v = v * decimal.Decimal(postPrefixes[text[-1]]) return v diff --git a/salt/modules/dockermod.py b/salt/modules/dockermod.py index 4bcf86ec4be..c67b6aef7f6 100644 --- a/salt/modules/dockermod.py +++ b/salt/modules/dockermod.py @@ -405,7 +405,6 @@ def _get_client(timeout=NOTSET, **kwargs): docker_machine_tls["ClientKeyPath"], ), ca_cert=docker_machine_tls["CaCertPath"], - assert_hostname=False, verify=True, ) except Exception as exc: # pylint: disable=broad-except @@ -696,9 +695,9 @@ def _client_wrapper(attr, *args, **kwargs): raise except docker.errors.DockerException as exc: # More general docker exception (catches InvalidVersion, etc.) - raise CommandExecutionError(exc.__str__()) + raise CommandExecutionError(str(exc)) except Exception as exc: # pylint: disable=broad-except - err = exc.__str__() + err = str(exc) else: return ret @@ -1339,7 +1338,10 @@ def compare_networks(first, second, ignore="Name,Id,Created,Containers"): if bool(subval1) is bool(subval2) is False: continue elif subkey == "Config": - kvsort = lambda x: (list(x.keys()), list(x.values())) + + def kvsort(x): + return (list(x.keys()), list(x.values())) + config1 = sorted(val1["Config"], key=kvsort) config2 = sorted(val2.get("Config", []), key=kvsort) if config1 != config2: @@ -3318,7 +3320,7 @@ def create( except CommandExecutionError as exc: raise CommandExecutionError( "Failed to start container after creation", - info={"response": response, "error": exc.__str__()}, + info={"response": response, "error": str(exc)}, ) else: response["Started"] = True @@ -3508,7 +3510,7 @@ def run_container( f"Failed to auto_remove container: {rm_exc}" ) # Raise original exception with additional info - raise CommandExecutionError(exc.__str__(), info=exc_info) + raise CommandExecutionError(str(exc), info=exc_info) # Start the container output = [] @@ -3560,7 +3562,7 @@ def run_container( # it to other_errors as a fallback. exc_info.setdefault("other_errors", []).append(exc.info) # Re-raise with all of the available additional info - raise CommandExecutionError(exc.__str__(), info=exc_info) + raise CommandExecutionError(str(exc), info=exc_info) return ret @@ -4292,7 +4294,7 @@ def dangling(prune=False, force=False): try: ret.setdefault(image, {})["Removed"] = rmi(image, force=force) except Exception as exc: # pylint: disable=broad-except - err = exc.__str__() + err = str(exc) log.error(err) ret.setdefault(image, {})["Comment"] = err ret[image]["Removed"] = False @@ -4612,7 +4614,7 @@ def pull( except Exception as exc: # pylint: disable=broad-except raise CommandExecutionError( f"Unable to interpret API event: '{event}'", - info={"Error": exc.__str__()}, + info={"Error": str(exc)}, ) try: event_type = next(iter(event)) @@ -4706,7 +4708,7 @@ def push( except Exception as exc: # pylint: disable=broad-except raise CommandExecutionError( f"Unable to interpret API event: '{event}'", - info={"Error": exc.__str__()}, + info={"Error": str(exc)}, ) try: event_type = next(iter(event)) @@ -5502,7 +5504,7 @@ def disconnect_all_containers_from_network(network_id): disconnect_container_from_network(cname, network_id) ret.append(cname) except CommandExecutionError as exc: - msg = exc.__str__() + msg = str(exc) if "404" not in msg: # If 404 was in the error, then the container no longer exists, # so to avoid a race condition we won't consider 404 errors to diff --git a/salt/modules/ebuildpkg.py b/salt/modules/ebuildpkg.py index 905f0339250..31f1fc6d516 100644 --- a/salt/modules/ebuildpkg.py +++ b/salt/modules/ebuildpkg.py @@ -148,9 +148,9 @@ def _process_emerge_err(stdout, stderr): if slot_conflicts: ret["slot conflicts"] = slot_conflicts - blocked = re.compile( - r"(?m)^\[blocks .+\] " r"([^ ]+/[^ ]+-[0-9]+[^ ]+)" r".*$" - ).findall(stdout) + blocked = re.compile(r"(?m)^\[blocks .+\] ([^ ]+/[^ ]+-[0-9]+[^ ]+).*$").findall( + stdout + ) unsatisfied = re.compile(r"Error: The above package list contains").findall(stderr) @@ -331,7 +331,9 @@ def _get_upgradable(backtrack=3): r".*$" ) keys = ["name", "version"] - _get = lambda l, k: l[keys.index(k)] + + def _get(line, k): + return line[keys.index(k)] upgrades = rexp.findall(out) diff --git a/salt/modules/file.py b/salt/modules/file.py index e826c435d45..53a666f1d2e 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -4123,7 +4123,7 @@ def readlink(path, canonicalize=False): except OSError as exc: if exc.errno == errno.EINVAL: raise CommandExecutionError(f"Not a symbolic link: {path}") - raise CommandExecutionError(exc.__str__()) + raise CommandExecutionError(str(exc)) def readdir(path): @@ -6063,7 +6063,7 @@ def get_diff( continue paths.append(cached_path) except MinionError as exc: - errors.append(salt.utils.stringutils.to_unicode(exc.__str__())) + errors.append(salt.utils.stringutils.to_unicode(str(exc))) continue if errors: diff --git a/salt/modules/freebsdjail.py b/salt/modules/freebsdjail.py index 46c10f0be15..f86bdab07fd 100644 --- a/salt/modules/freebsdjail.py +++ b/salt/modules/freebsdjail.py @@ -125,9 +125,7 @@ def show_config(jail): """ ret = {} if subprocess.call(["jls", "-nq", "-j", jail]) == 0: - jls = subprocess.check_output( - ["jls", "-nq", "-j", jail] - ) # pylint: disable=minimum-python-version + jls = subprocess.check_output(["jls", "-nq", "-j", jail]) jailopts = salt.utils.args.shlex_split(salt.utils.stringutils.to_unicode(jls)) for jailopt in jailopts: if "=" not in jailopt: diff --git a/salt/modules/git.py b/salt/modules/git.py index 2de4155789c..4e2d2d0c5bf 100644 --- a/salt/modules/git.py +++ b/salt/modules/git.py @@ -1067,7 +1067,7 @@ def clone( url, https_user, https_pass, https_only=True ) except ValueError as exc: - raise SaltInvocationError(exc.__str__()) + raise SaltInvocationError(str(exc)) command = ["git"] + _format_git_opts(git_opts) command.append("clone") @@ -3044,7 +3044,7 @@ def ls_remote( remote, https_user, https_pass, https_only=True ) except ValueError as exc: - raise SaltInvocationError(exc.__str__()) + raise SaltInvocationError(str(exc)) command = ["git"] + _format_git_opts(git_opts) command.append("ls-remote") command.extend(_format_opts(opts)) @@ -4051,7 +4051,7 @@ def remote_refs( ) ) except ValueError as exc: - raise SaltInvocationError(exc.__str__()) + raise SaltInvocationError(str(exc)) if filter_: command.append(filter_) output = _git_run( @@ -4185,7 +4185,7 @@ def remote_set( url, https_user, https_pass, https_only=True ) except ValueError as exc: - raise SaltInvocationError(exc.__str__()) + raise SaltInvocationError(str(exc)) command = ["git", "remote", "add", remote, url] _git_run( command, diff --git a/salt/modules/glassfish.py b/salt/modules/glassfish.py index a41f21e419b..f98e7009d29 100644 --- a/salt/modules/glassfish.py +++ b/salt/modules/glassfish.py @@ -126,6 +126,7 @@ def _api_get(path, server=None): auth=_get_auth(server["user"], server["password"]), headers=_get_headers(), verify=True, + timeout=120, ) return _api_response(response) @@ -141,6 +142,7 @@ def _api_post(path, data, server=None): headers=_get_headers(), data=salt.utils.json.dumps(data), verify=True, + timeout=120, ) return _api_response(response) @@ -156,6 +158,7 @@ def _api_delete(path, data, server=None): headers=_get_headers(), params=data, verify=True, + timeout=120, ) return _api_response(response) diff --git a/salt/modules/grains.py b/salt/modules/grains.py index f60fb1bb053..c9f9d1481d5 100644 --- a/salt/modules/grains.py +++ b/salt/modules/grains.py @@ -38,8 +38,11 @@ __outputter__ = { "setval": "nested", } + # http://stackoverflow.com/a/12414913/127816 -_infinitedict = lambda: collections.defaultdict(_infinitedict) +def _infinitedict(): + return collections.defaultdict(_infinitedict) + _non_existent_key = "NonExistentValueMagicNumberSpK3hnufdHfeBUXCfqVK" @@ -53,21 +56,28 @@ def _serial_sanitizer(instr): return "{}{}".format(instr[:index], "X" * (length - index)) -_FQDN_SANITIZER = lambda x: "MINION.DOMAINNAME" -_HOSTNAME_SANITIZER = lambda x: "MINION" -_DOMAINNAME_SANITIZER = lambda x: "DOMAINNAME" +def _fqdn_sanitizer(x): + return "MINION.DOMAINNAME" + + +def _hostname_sanitizer(x): + return "MINION" + + +def _domainname_sanitizer(x): + return "DOMAINNAME" # A dictionary of grain -> function mappings for sanitizing grain output. This # is used when the 'sanitize' flag is given. _SANITIZERS = { "serialnumber": _serial_sanitizer, - "domain": _DOMAINNAME_SANITIZER, - "fqdn": _FQDN_SANITIZER, - "id": _FQDN_SANITIZER, - "host": _HOSTNAME_SANITIZER, - "localhost": _HOSTNAME_SANITIZER, - "nodename": _HOSTNAME_SANITIZER, + "domain": _domainname_sanitizer, + "fqdn": _fqdn_sanitizer, + "id": _fqdn_sanitizer, + "host": _hostname_sanitizer, + "localhost": _hostname_sanitizer, + "nodename": _hostname_sanitizer, } diff --git a/salt/modules/heat.py b/salt/modules/heat.py index b26277c1488..5a86b2b1fec 100644 --- a/salt/modules/heat.py +++ b/salt/modules/heat.py @@ -241,9 +241,15 @@ def _poll_for_events( """ if action: stop_status = (f"{action}_FAILED", f"{action}_COMPLETE") - stop_check = lambda a: a in stop_status + + def stop_check(a): + return a in stop_status + else: - stop_check = lambda a: a.endswith("_COMPLETE") or a.endswith("_FAILED") + + def stop_check(a): + return a.endswith("_COMPLETE") or a.endswith("_FAILED") + timeout_sec = timeout * 60 no_event_polls = 0 msg_template = "\n Stack %(name)s %(status)s \n" diff --git a/salt/modules/inspectlib/fsdb.py b/salt/modules/inspectlib/fsdb.py index daa9a74ded4..787be0c0252 100644 --- a/salt/modules/inspectlib/fsdb.py +++ b/salt/modules/inspectlib/fsdb.py @@ -16,15 +16,12 @@ """ :codeauthor: Bo Maryniuk """ - - import csv import datetime import gzip import os import re import shutil -import sys from salt.utils.odict import OrderedDict @@ -182,7 +179,10 @@ class CsvDB: :param obj: :return: """ - get_type = lambda item: str(type(item)).split("'")[1] + + def get_type(item): + return str(type(item)).split("'")[1] + if not os.path.exists(os.path.join(self.db_path, obj._TABLE)): with gzip.open(os.path.join(self.db_path, obj._TABLE), "wt") as table_file: csv.writer(table_file).writerow( @@ -333,14 +333,10 @@ class CsvDB: return objects def _to_type(self, data, type): - if type == "int": + if type in ("int", "long"): data = int(data) elif type == "float": data = float(data) - elif type == "long": - # pylint: disable=undefined-variable,incompatible-py3-code - data = sys.version_info[0] == 2 and long(data) or int(data) - # pylint: enable=undefined-variable,incompatible-py3-code else: data = str(data) return data diff --git a/salt/modules/inspectlib/query.py b/salt/modules/inspectlib/query.py index cfc372486a0..d7f06eae565 100644 --- a/salt/modules/inspectlib/query.py +++ b/salt/modules/inspectlib/query.py @@ -480,11 +480,13 @@ class Query(EnvLoader): raise InspectorQueryException( f'Unknown "{timeformat}" value for parameter "time"' ) - tfmt = ( - lambda param: timeformat == "tz" - and time.strftime("%b %d %Y %H:%M:%S", time.gmtime(param)) - or int(param) - ) + + def tfmt(param): + return ( + timeformat == "tz" + and time.strftime("%b %d %Y %H:%M:%S", time.gmtime(param)) + or int(param) + ) size_fmt = kwargs.get("size") if size_fmt is not None and size_fmt.lower() not in ["b", "kb", "mb", "gb"]: @@ -525,9 +527,9 @@ class Query(EnvLoader): pld_files.append(pld_data.path) else: pld_files[pld_data.path] = { - "uid": self._id_resolv(pld_data.uid, named=(owners == "id")), + "uid": self._id_resolv(pld_data.uid, named=owners == "id"), "gid": self._id_resolv( - pld_data.gid, named=(owners == "id"), uid=False + pld_data.gid, named=owners == "id", uid=False ), "size": _size_format(pld_data.p_size, fmt=size_fmt), "mode": oct(pld_data.mode), diff --git a/salt/modules/iptables.py b/salt/modules/iptables.py index c159dde87f3..986005b1f71 100644 --- a/salt/modules/iptables.py +++ b/salt/modules/iptables.py @@ -25,11 +25,11 @@ master config. The configuration is read using :py:func:`config.get - "-A FORWARD" """ +import argparse import logging import os import re import string -import sys import uuid import salt.utils.args @@ -1080,17 +1080,8 @@ def _parser(): iptables(8) and iptables-extensions(8) man pages. They will not all be used by all parts of the module; use them intelligently and appropriately. """ - add_arg = None - if sys.version.startswith("2.6"): - import optparse - - parser = optparse.OptionParser() - add_arg = parser.add_option - else: - import argparse # pylint: disable=minimum-python-version - - parser = argparse.ArgumentParser() - add_arg = parser.add_argument + parser = argparse.ArgumentParser() + add_arg = parser.add_argument # COMMANDS add_arg("-A", "--append", dest="append", action="append") diff --git a/salt/modules/iwtools.py b/salt/modules/iwtools.py index 198375d9850..d22b16133f1 100644 --- a/salt/modules/iwtools.py +++ b/salt/modules/iwtools.py @@ -112,7 +112,7 @@ def _valid_iface(iface): Validate the specified interface """ ifaces = list_interfaces() - if iface in ifaces.keys(): + if iface in ifaces: return True return False diff --git a/salt/modules/k8s.py b/salt/modules/k8s.py index 9c3095b9308..382c3ee7b4f 100644 --- a/salt/modules/k8s.py +++ b/salt/modules/k8s.py @@ -587,7 +587,7 @@ def _source_encode(source, saltenv): try: source_url = urllib.parse.urlparse(source) except TypeError: - return "", {}, "Invalid format for source parameter" + return "", {} protos = ("salt", "http", "https", "ftp", "swift", "s3", "file") diff --git a/salt/modules/kubernetesmod.py b/salt/modules/kubernetesmod.py index a0a3f2de44e..491d5c132ac 100644 --- a/salt/modules/kubernetesmod.py +++ b/salt/modules/kubernetesmod.py @@ -160,7 +160,7 @@ def _setup_conn_old(**kwargs): or kubernetes.client.configuration.password != password ): # Recreates API connection if settings are changed - kubernetes.client.configuration.__init__() + kubernetes.client.configuration.__init__() # pylint: disable=unnecessary-dunder-call kubernetes.client.configuration.host = host kubernetes.client.configuration.user = username diff --git a/salt/modules/ldap3.py b/salt/modules/ldap3.py index d7e0834d341..8261dc2f5f7 100644 --- a/salt/modules/ldap3.py +++ b/salt/modules/ldap3.py @@ -31,7 +31,9 @@ log = logging.getLogger(__name__) def __virtual__(): """Only load this module if the Python ldap module is present""" - return bool(len(available_backends)) + if available_backends: + return True + return False class LDAPError(Exception): diff --git a/salt/modules/mac_brew_pkg.py b/salt/modules/mac_brew_pkg.py index ff20b3f483f..1a264b21ba9 100644 --- a/salt/modules/mac_brew_pkg.py +++ b/salt/modules/mac_brew_pkg.py @@ -194,7 +194,7 @@ def homebrew_prefix(): # If HOMEBREW_PREFIX env variable is present, use it env_homebrew_prefix = "HOMEBREW_PREFIX" if env_homebrew_prefix in os.environ: - log.debug(f"{env_homebrew_prefix} is set. Using it for homebrew prefix.") + log.debug("%s is set. Using it for homebrew prefix.", env_homebrew_prefix) return os.environ[env_homebrew_prefix] # Try brew --prefix otherwise @@ -213,9 +213,9 @@ def homebrew_prefix(): ) return ret - except CommandExecutionError as e: + except CommandExecutionError as exc: log.debug( - f"Unable to find homebrew prefix by running 'brew --prefix'. Error: {str(e)}" + "Unable to find homebrew prefix by running 'brew --prefix'. Error: %s", exc ) return None diff --git a/salt/modules/mac_softwareupdate.py b/salt/modules/mac_softwareupdate.py index 22d69f7199e..9ca40a2417d 100644 --- a/salt/modules/mac_softwareupdate.py +++ b/salt/modules/mac_softwareupdate.py @@ -176,7 +176,7 @@ def list_ignored(): # "Safari6.1.2MountainLion-6.1.2", # or: # Safari6.1.2MountainLion-6.1.2 - rexp = re.compile('(?m)^ ["]?' r'([^,|\s].*[^"|\n|,])[,|"]?') + rexp = re.compile(r'(?m)^ ["]?([^,|\s].*[^"|\n|,])[,|"]?') return rexp.findall(out) diff --git a/salt/modules/mine.py b/salt/modules/mine.py index 758ec9e4e1d..69bd6fe4492 100644 --- a/salt/modules/mine.py +++ b/salt/modules/mine.py @@ -186,7 +186,7 @@ def update(clear=False, mine_functions=None): res = salt.utils.functools.call_function( __salt__[function_name or function_alias], *function_args, - **function_kwargs + **function_kwargs, ) except Exception: # pylint: disable=broad-except trace = traceback.format_exc() @@ -320,8 +320,7 @@ def get(tgt, fun, tgt_type="glob", exclude_minion=False): "pillar": __salt__["match.pillar"], "pillar_pcre": __salt__["match.pillar_pcre"], } - is_target = _targets[tgt_type](tgt) - if not is_target: + if not _targets[tgt_type](tgt): return ret data = __salt__["data.get"]("mine_cache") diff --git a/salt/modules/mount.py b/salt/modules/mount.py index 413efb98bf0..7ba80bf48d0 100644 --- a/salt/modules/mount.py +++ b/salt/modules/mount.py @@ -16,10 +16,8 @@ import salt.utils.stringutils from salt.exceptions import CommandExecutionError, CommandNotFoundError from salt.utils.odict import OrderedDict -# Set up logger log = logging.getLogger(__name__) -# Define the module's virtual name __virtualname__ = "mount" @@ -863,7 +861,10 @@ def set_fstab( criteria = entry.pick(match_on) except KeyError: - filterFn = lambda key: key not in _fstab_entry.fstab_keys + + def filterFn(key): + return key not in _fstab_entry.fstab_keys + invalid_keys = filter(filterFn, match_on) msg = f'Unrecognized keys in match_on: "{invalid_keys}"' @@ -993,7 +994,10 @@ def set_vfstab( criteria = entry.pick(match_on) except KeyError: - filterFn = lambda key: key not in _vfstab_entry.vfstab_keys + + def filterFn(key): + return key not in _vfstab_entry.vfstab_keys + invalid_keys = filter(filterFn, match_on) msg = f'Unrecognized keys in match_on: "{invalid_keys}"' @@ -1418,7 +1422,7 @@ def umount(name, device=None, user=None, util="mount", lazy=False): if not device: cmd = f"{cmd} '{name}'" else: - cmd = f"{cmd}'{device}'" + cmd = f"{cmd} '{device}'" out = __salt__["cmd.run_all"](cmd, runas=user, python_shell=False) if out["retcode"]: @@ -1879,7 +1883,10 @@ def set_filesystems( criteria = entry_ip.pick(match_on) except KeyError: - filterFn = lambda key: key not in _FileSystemsEntry.compatibility_keys + + def filterFn(key): + return key not in _FileSystemsEntry.compatibility_keys + invalid_keys = filter(filterFn, match_on) raise CommandExecutionError(f'Unrecognized keys in match_on: "{invalid_keys}"') diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py index 5a0820c0400..2558edd0111 100644 --- a/salt/modules/mysql.py +++ b/salt/modules/mysql.py @@ -2394,7 +2394,7 @@ def __grant_generate( if dbc != "*": # _ and % are authorized on GRANT queries and should get escaped # on the db name, but only if not requesting a table level grant - dbc = quote_identifier(dbc, for_grants=(table == "*")) + dbc = quote_identifier(dbc, for_grants=table == "*") if table != "*": table = quote_identifier(table) # identifiers cannot be used as values, and same thing for grants @@ -2663,7 +2663,7 @@ def grant_revoke( if dbc != "*": # _ and % are authorized on GRANT queries and should get escaped # on the db name, but only if not requesting a table level grant - s_database = quote_identifier(dbc, for_grants=(table == "*")) + s_database = quote_identifier(dbc, for_grants=table == "*") if dbc == "*": # add revoke for *.* # before the modification query send to mysql will looks like @@ -2764,11 +2764,13 @@ def __do_query_into_hash(conn, sql_str): rtn_results = [] + cursor = None try: cursor = conn.cursor() except MySQLdb.MySQLError: log.error("%s: Can't get cursor for SQL->%s", mod, sql_str) - cursor.close() + if cursor: + cursor.close() log.debug("%s-->", mod) return rtn_results diff --git a/salt/modules/network.py b/salt/modules/network.py index de407956767..efc8a7a3617 100644 --- a/salt/modules/network.py +++ b/salt/modules/network.py @@ -2069,7 +2069,7 @@ def iphexval(ip): salt '*' network.iphexval 10.0.0.1 """ a = ip.split(".") - hexval = ["%02X" % int(x) for x in a] # pylint: disable=E1321 + hexval = ["%02X" % int(x) for x in a] return "".join(hexval) diff --git a/salt/modules/openscap.py b/salt/modules/openscap.py index fb03a3e950a..6b19aa955d2 100644 --- a/salt/modules/openscap.py +++ b/salt/modules/openscap.py @@ -28,7 +28,6 @@ class _ArgumentParser(argparse.ArgumentParser): def __init__(self, action=None, *args, **kwargs): super().__init__(*args, prog="oscap", **kwargs) self.add_argument("action", choices=["eval"]) - add_arg = None for params, kwparams in _XCCDF_MAP["eval"]["parser_arguments"]: self.add_argument(*params, **kwparams) diff --git a/salt/modules/opkg.py b/salt/modules/opkg.py index 7176c865347..725a222b5d4 100644 --- a/salt/modules/opkg.py +++ b/salt/modules/opkg.py @@ -1222,7 +1222,10 @@ def version_cmp( salt '*' pkg.version_cmp '0.2.4-0' '0.2.4.1-0' """ - normalize = lambda x: str(x).split(":", 1)[-1] if ignore_epoch else str(x) + + def normalize(x): + return str(x).split(":", 1)[-1] if ignore_epoch else str(x) + pkg1 = normalize(pkg1) pkg2 = normalize(pkg2) diff --git a/salt/modules/opsgenie.py b/salt/modules/opsgenie.py index 18539b80654..7ed014042a0 100644 --- a/salt/modules/opsgenie.py +++ b/salt/modules/opsgenie.py @@ -99,6 +99,7 @@ def post_data( "Content-Type": "application/json", "Authorization": "GenieKey " + api_key, }, + timeout=120, ) else: response = requests.post( @@ -108,6 +109,7 @@ def post_data( "Content-Type": "application/json", "Authorization": "GenieKey " + api_key, }, + timeout=120, ) return response.status_code, response.text diff --git a/salt/modules/oracle.py b/salt/modules/oracle.py index bc80943d480..bb79063533f 100644 --- a/salt/modules/oracle.py +++ b/salt/modules/oracle.py @@ -180,9 +180,12 @@ def version(*dbs): salt '*' oracle.version my_db """ pillar_dbs = __salt__["pillar.get"]("oracle:dbs") - get_version = lambda x: [ - r[0] for r in run_query(x, "select banner from v$version order by banner") - ] + + def get_version(x): + return [ + r[0] for r in run_query(x, "select banner from v$version order by banner") + ] + result = {} if dbs: log.debug("get db versions for: %s", dbs) diff --git a/salt/modules/pagerduty_util.py b/salt/modules/pagerduty_util.py index 76e508b5e10..7485fa30e2f 100644 --- a/salt/modules/pagerduty_util.py +++ b/salt/modules/pagerduty_util.py @@ -174,6 +174,7 @@ def _query( params=params, data=salt.utils.json.dumps(data), verify=verify_ssl, + timeout=120, ) if result.text is None or result.text == "": @@ -196,6 +197,7 @@ def _query( params=params, data=data, # Already serialized above, don't do it again verify=verify_ssl, + timeout=120, ).json() offset = next_page_results["offset"] limit = next_page_results["limit"] diff --git a/salt/modules/pkg_resource.py b/salt/modules/pkg_resource.py index 1f8e3c2e141..88e38b91a41 100644 --- a/salt/modules/pkg_resource.py +++ b/salt/modules/pkg_resource.py @@ -25,7 +25,9 @@ def _repack_pkgs(pkgs, normalize=True): if normalize and "pkg.normalize_name" in __salt__: _normalize_name = __salt__["pkg.normalize_name"] else: - _normalize_name = lambda pkgname: pkgname + + def _normalize_name(pkgname): + return pkgname repacked_pkgs = { _normalize_name(str(x)): str(y) if y is not None else y @@ -70,7 +72,9 @@ def pack_sources(sources, normalize=True): if normalize and "pkg.normalize_name" in __salt__: _normalize_name = __salt__["pkg.normalize_name"] else: - _normalize_name = lambda pkgname: pkgname + + def _normalize_name(pkgname): + return pkgname if isinstance(sources, str): try: diff --git a/salt/modules/portage_config.py b/salt/modules/portage_config.py index 2e2c03c82a8..bd2f18b5c42 100644 --- a/salt/modules/portage_config.py +++ b/salt/modules/portage_config.py @@ -88,7 +88,7 @@ def _get_config_file(conf, atom): # parts.repo will be empty if there is no repo part relative_path = parts.repo or "gentoo" elif str(parts.cp).endswith("/*"): - relative_path = str(parts.cp).split("/")[0] + "_" + relative_path = str(parts.cp).split("/", maxsplit=1)[0] + "_" else: relative_path = os.path.join( *[x for x in os.path.split(parts.cp) if x != "*"] diff --git a/salt/modules/postgres.py b/salt/modules/postgres.py index 270a0a6ad46..85656cc2612 100644 --- a/salt/modules/postgres.py +++ b/salt/modules/postgres.py @@ -35,10 +35,6 @@ To prevent Postgres commands from running arbitrarily long, a timeout (in second postgres.bins_dir: '/usr/pgsql-9.5/bin/' """ -# This pylint error is popping up where there are no colons? -# pylint: disable=E8203 - - import base64 import datetime import hashlib @@ -1007,7 +1003,8 @@ def user_list( return False # will return empty string if return_password = False - _x = lambda s: s if return_password else "" + def _x(s): + return s if return_password else "" query = "".join( [ diff --git a/salt/modules/ps.py b/salt/modules/ps.py index b2eccab73d2..e659a702b18 100644 --- a/salt/modules/ps.py +++ b/salt/modules/ps.py @@ -2,8 +2,7 @@ A salt interface to psutil, a system and process library. See http://code.google.com/p/psutil. -:depends: - psutil Python module, version 0.3.0 or later - - python-utmp package (optional) +:depends: - python-utmp package (optional) """ import datetime @@ -14,15 +13,12 @@ import salt.utils.data import salt.utils.decorators.path from salt.exceptions import CommandExecutionError, SaltInvocationError -# pylint: disable=import-error try: - import salt.utils.psutil_compat as psutil + import psutil HAS_PSUTIL = True - PSUTIL2 = getattr(psutil, "version_info", ()) >= (2, 0) except ImportError: HAS_PSUTIL = False -# pylint: enable=import-error def __virtual__(): @@ -31,21 +27,7 @@ def __virtual__(): False, "The ps module cannot be loaded: python module psutil not installed.", ) - - # Functions and attributes used in this execution module seem to have been - # added as of psutil 0.3.0, from an inspection of the source code. Only - # make this module available if the version of psutil is >= 0.3.0. Note - # that this may need to be tweaked if we find post-0.3.0 versions which - # also have problems running the functions in this execution module, but - # most distributions have already moved to later versions (for example, - # as of Dec. 2013 EPEL is on 0.6.1, Debian 7 is on 0.5.1, etc.). - if psutil.version_info >= (0, 3, 0): - return True - return ( - False, - "The ps execution module cannot be loaded: the psutil python module version {}" - " is less than 0.3.0".format(psutil.version_info), - ) + return True def _get_proc_cmdline(proc): @@ -55,7 +37,7 @@ def _get_proc_cmdline(proc): It's backward compatible with < 2.0 versions of psutil. """ try: - return salt.utils.data.decode(proc.cmdline() if PSUTIL2 else proc.cmdline) + return salt.utils.data.decode(proc.cmdline()) except (psutil.NoSuchProcess, psutil.AccessDenied): return [] @@ -67,9 +49,7 @@ def _get_proc_create_time(proc): It's backward compatible with < 2.0 versions of psutil. """ try: - return salt.utils.data.decode( - proc.create_time() if PSUTIL2 else proc.create_time - ) + return salt.utils.data.decode(proc.create_time()) except (psutil.NoSuchProcess, psutil.AccessDenied): return None @@ -81,7 +61,7 @@ def _get_proc_name(proc): It's backward compatible with < 2.0 versions of psutil. """ try: - return salt.utils.data.decode(proc.name() if PSUTIL2 else proc.name) + return salt.utils.data.decode(proc.name()) except (psutil.NoSuchProcess, psutil.AccessDenied): return [] @@ -93,7 +73,7 @@ def _get_proc_status(proc): It's backward compatible with < 2.0 versions of psutil. """ try: - return salt.utils.data.decode(proc.status() if PSUTIL2 else proc.status) + return salt.utils.data.decode(proc.status()) except (psutil.NoSuchProcess, psutil.AccessDenied): return None @@ -105,7 +85,7 @@ def _get_proc_username(proc): It's backward compatible with < 2.0 versions of psutil. """ try: - return salt.utils.data.decode(proc.username() if PSUTIL2 else proc.username) + return salt.utils.data.decode(proc.username()) except (psutil.NoSuchProcess, psutil.AccessDenied, KeyError): return None @@ -441,9 +421,6 @@ def virtual_memory(): salt '*' ps.virtual_memory """ - if psutil.version_info < (0, 6, 0): - msg = "virtual_memory is only available in psutil 0.6.0 or greater" - raise CommandExecutionError(msg) return dict(psutil.virtual_memory()._asdict()) @@ -463,9 +440,6 @@ def swap_memory(): salt '*' ps.swap_memory """ - if psutil.version_info < (0, 6, 0): - msg = "swap_memory is only available in psutil 0.6.0 or greater" - raise CommandExecutionError(msg) return dict(psutil.swap_memory()._asdict()) @@ -529,9 +503,6 @@ def total_physical_memory(): salt '*' ps.total_physical_memory """ - if psutil.version_info < (0, 6, 0): - msg = "virtual_memory is only available in psutil 0.6.0 or greater" - raise CommandExecutionError(msg) try: return psutil.virtual_memory().total except AttributeError: diff --git a/salt/modules/quota.py b/salt/modules/quota.py index ec9f20ca3fd..39bd3c5b1ce 100644 --- a/salt/modules/quota.py +++ b/salt/modules/quota.py @@ -105,7 +105,7 @@ def set_(device, **kwargs): "file-hard-limit": 0, } - current = None + current = ret = None cmd = "setquota" if "user" in kwargs: cmd += " -u {} ".format(kwargs["user"]) diff --git a/salt/modules/rabbitmq.py b/salt/modules/rabbitmq.py index 5ad42678489..42f148ed476 100644 --- a/salt/modules/rabbitmq.py +++ b/salt/modules/rabbitmq.py @@ -163,7 +163,9 @@ def _output_to_dict(cmdoutput, values_mapper=None): ret = {} if values_mapper is None: - values_mapper = lambda string: string.split("\t") + + def values_mapper(string): + return string.split("\t") # remove first and last line: Listing ... - ...done data_rows = _strip_listing_to_done(cmdoutput.splitlines()) @@ -235,11 +237,11 @@ def list_users(runas=None): ) # func to get tags from string such as "[admin, monitoring]" - func = lambda string: ( - [x.strip() for x in string[1:-1].split(",")] - if "," in string - else [x for x in string[1:-1].split(" ")] - ) + def func(string): + if "," in string: + return [x.strip() for x in string[1:-1].split(",")] + return [x for x in string[1:-1].split(" ")] + return _output_to_dict(res, func) diff --git a/salt/modules/rpm_lowpkg.py b/salt/modules/rpm_lowpkg.py index 59bf0fa9fb4..1e3aa32e958 100644 --- a/salt/modules/rpm_lowpkg.py +++ b/salt/modules/rpm_lowpkg.py @@ -710,7 +710,10 @@ def version_cmp(ver1, ver2, ignore_epoch=False): salt '*' pkg.version_cmp '0.2-001' '0.2.0.1-002' """ - normalize = lambda x: str(x).split(":", 1)[-1] if ignore_epoch else str(x) + + def normalize(x): + return str(x).split(":", 1)[-1] if ignore_epoch else str(x) + ver1 = normalize(ver1) ver2 = normalize(ver2) diff --git a/salt/modules/saltcheck.py b/salt/modules/saltcheck.py index 816860f16c8..d49f69346b2 100644 --- a/salt/modules/saltcheck.py +++ b/salt/modules/saltcheck.py @@ -486,7 +486,7 @@ def run_state_tests( results_dict = OrderedDict() # Check for situations to disable parallization if parallel: - if type(num_proc) == float: + if isinstance(num_proc, float): num_proc = int(num_proc) if multiprocessing.cpu_count() < 2: diff --git a/salt/modules/saltutil.py b/salt/modules/saltutil.py index 0095871116b..00344d70083 100644 --- a/salt/modules/saltutil.py +++ b/salt/modules/saltutil.py @@ -50,7 +50,12 @@ try: except ImportError: HAS_ESKY = False -# pylint: enable=import-error,no-name-in-module +try: + import psutil + + HAS_PSUTIL = True +except ImportError: + HAS_PSUTIL = False # Fix a nasty bug with Win32 Python not supporting all of the standard signals try: @@ -59,13 +64,6 @@ except AttributeError: salt_SIGKILL = signal.SIGTERM -HAS_PSUTIL = True -try: - import salt.utils.psutil_compat -except ImportError: - HAS_PSUTIL = False - - __proxyenabled__ = ["*"] log = logging.getLogger(__name__) @@ -1549,9 +1547,9 @@ def signal_job(jid, sig): if data["jid"] == jid: try: if HAS_PSUTIL: - for proc in salt.utils.psutil_compat.Process( - pid=data["pid"] - ).children(recursive=True): + for proc in psutil.Process(pid=data["pid"]).children( + recursive=True + ): proc.send_signal(sig) os.kill(int(data["pid"]), sig) if HAS_PSUTIL is False and "child_pids" in data: diff --git a/salt/modules/selinux.py b/salt/modules/selinux.py index 46ce1ec8b20..21471397ea4 100644 --- a/salt/modules/selinux.py +++ b/salt/modules/selinux.py @@ -374,7 +374,7 @@ def _validate_filetype(filetype): Checks if the given filetype is a valid SELinux filetype specification. Throws an SaltInvocationError if it isn't. """ - if filetype not in _SELINUX_FILETYPES.keys(): + if filetype not in _SELINUX_FILETYPES: raise SaltInvocationError(f"Invalid filetype given: {filetype}") return True diff --git a/salt/modules/sensehat.py b/salt/modules/sensehat.py index c3f3e2f0a6d..404f469933d 100644 --- a/salt/modules/sensehat.py +++ b/salt/modules/sensehat.py @@ -38,6 +38,7 @@ def __virtual__(): """ if has_sense_hat: try: + global _sensehat _sensehat = SenseHat() except OSError: return ( diff --git a/salt/modules/serverdensity_device.py b/salt/modules/serverdensity_device.py index 7b653d9bcb8..741e2c52b68 100644 --- a/salt/modules/serverdensity_device.py +++ b/salt/modules/serverdensity_device.py @@ -88,6 +88,7 @@ def create(name, **params): "https://api.serverdensity.io/inventory/devices/", params={"token": get_sd_auth("api_token")}, data=params, + timeout=120, ) log.debug("Server Density API Response: %s", api_response) log.debug("Server Density API Response content: %s", api_response.content) @@ -119,6 +120,7 @@ def delete(device_id): api_response = requests.delete( "https://api.serverdensity.io/inventory/devices/" + device_id, params={"token": get_sd_auth("api_token")}, + timeout=120, ) log.debug("Server Density API Response: %s", api_response) log.debug("Server Density API Response content: %s", api_response.content) @@ -170,6 +172,7 @@ def ls(**params): "token": get_sd_auth("api_token"), "filter": salt.utils.json.dumps(params), }, + timeout=120, ) log.debug("Server Density API Response: %s", api_response) log.debug("Server Density API Response content: %s", api_response.content) @@ -208,6 +211,7 @@ def update(device_id, **params): "https://api.serverdensity.io/inventory/devices/" + device_id, params={"token": get_sd_auth("api_token")}, data=params, + timeout=120, ) log.debug("Server Density API Response: %s", api_response) log.debug("Server Density API Response content: %s", api_response.content) diff --git a/salt/modules/solaris_shadow.py b/salt/modules/solaris_shadow.py index fcf7e934cfd..36d34d81e72 100644 --- a/salt/modules/solaris_shadow.py +++ b/salt/modules/solaris_shadow.py @@ -114,7 +114,7 @@ def info(name): } try: - data = pwd.getpwnam(name) + data = pwd.getpwnam(name) # pylint: disable=used-before-assignment ret.update({"name": name}) except KeyError: return ret diff --git a/salt/modules/splunk_search.py b/salt/modules/splunk_search.py index d6de25eba63..51f46cfc7d9 100644 --- a/salt/modules/splunk_search.py +++ b/salt/modules/splunk_search.py @@ -162,7 +162,7 @@ def create(name, profile="splunk", **kwargs): _req_url = "{}/servicesNS/{}/search/saved/searches/{}/acl".format( url, config.get("username"), urllib.parse.quote(name) ) - requests.post(_req_url, auth=auth, verify=True, data=data) + requests.post(_req_url, auth=auth, verify=True, data=data, timeout=120) return _get_splunk_search_props(search) diff --git a/salt/modules/status.py b/salt/modules/status.py index ba4567cd48a..71fa6f49cc9 100644 --- a/salt/modules/status.py +++ b/salt/modules/status.py @@ -186,10 +186,10 @@ def custom(): try: ret[item] = vals[item] except KeyError: - log.warning(f"val {item} not in return of {func}") + log.warning("val %s not in return of %s", item, func) ret[item] = "UNKNOWN" except KeyError: - log.warning(f"custom status {func} isn't loaded") + log.warning("custom status %s isn't loaded", func) return ret @@ -1359,7 +1359,10 @@ def netdev(): """ freebsd specific implementation of netdev """ - _dict_tree = lambda: collections.defaultdict(_dict_tree) + + def _dict_tree(): + return collections.defaultdict(_dict_tree) + ret = _dict_tree() netstat = __salt__["cmd.run"]("netstat -i -n -4 -b -d").splitlines() netstat += __salt__["cmd.run"]("netstat -i -n -6 -b -d").splitlines()[1:] diff --git a/salt/modules/statuspage.py b/salt/modules/statuspage.py index 09b8cd0b2d6..4670d628151 100644 --- a/salt/modules/statuspage.py +++ b/salt/modules/statuspage.py @@ -109,7 +109,7 @@ def _http_request(url, method="GET", headers=None, data=None): """ Make the HTTP request and return the body as python object. """ - req = requests.request(method, url, headers=headers, data=data) + req = requests.request(method, url, headers=headers, data=data, timeout=120) ret = _default_ret() ok_status = METHOD_OK_STATUS.get(method, 200) if req.status_code != ok_status: diff --git a/salt/modules/swarm.py b/salt/modules/swarm.py index fb0d1e273e6..48d49130274 100644 --- a/salt/modules/swarm.py +++ b/salt/modules/swarm.py @@ -374,7 +374,7 @@ def node_ls(server=str): try: salt_return = {} client = docker.APIClient(base_url="unix://var/run/docker.sock") - service = client.nodes(filters=({"name": server})) + service = client.nodes(filters={"name": server}) getdata = salt.utils.json.dumps(service) dump = salt.utils.json.loads(getdata) for items in dump: diff --git a/salt/modules/sysrc.py b/salt/modules/sysrc.py index 25533f8eec8..1f3fc90f2a0 100644 --- a/salt/modules/sysrc.py +++ b/salt/modules/sysrc.py @@ -93,14 +93,14 @@ def set_(name, value, **kwargs): # YES, NO, Yes, No, True, False, etc. to boolean types. However, in this case, # we will check to see if that happened and replace it with "YES" or "NO" because # those items are accepted in sysrc. - if type(value) == bool: + if isinstance(value, bool): if value: value = "YES" else: value = "NO" # This is here for the same reason, except for numbers - if type(value) == int: + if isinstance(value, int): value = str(value) cmd += " " + name + '="' + value + '"' diff --git a/salt/modules/systemd_service.py b/salt/modules/systemd_service.py index 39fe6f9c043..27ecaf03363 100644 --- a/salt/modules/systemd_service.py +++ b/salt/modules/systemd_service.py @@ -55,9 +55,6 @@ VALID_UNIT_TYPES = ( # Define the module's virtual name __virtualname__ = "service" -# Disable check for string substitution -# pylint: disable=E1321 - def __virtual__(): """ diff --git a/salt/modules/telegram.py b/salt/modules/telegram.py index 13fceb4cfff..3d1e73cca4d 100644 --- a/salt/modules/telegram.py +++ b/salt/modules/telegram.py @@ -113,7 +113,7 @@ def _post_message(message, chat_id, token): parameters["text"] = message try: - response = requests.post(url, data=parameters) + response = requests.post(url, data=parameters, timeout=120) result = response.json() log.debug("Raw response of the telegram request is %s", response) diff --git a/salt/modules/telemetry.py b/salt/modules/telemetry.py index 450ff383b28..3fc4b902d5c 100644 --- a/salt/modules/telemetry.py +++ b/salt/modules/telemetry.py @@ -101,7 +101,7 @@ def _retrieve_channel_id(email, profile="telemetry"): _get_telemetry_base(profile) + "/notification-channels?_type=EmailNotificationChannel" ) - response = requests.get(get_url, headers=auth) + response = requests.get(get_url, headers=auth, timeout=120) if response.status_code == 200: cache_result = {} @@ -140,7 +140,7 @@ def get_alert_config( get_url = _get_telemetry_base(profile) + "/alerts?deployment={}".format( deployment_id ) - response = requests.get(get_url, headers=auth) + response = requests.get(get_url, headers=auth, timeout=120) except requests.exceptions.RequestException as e: log.error(str(e)) return False @@ -197,7 +197,7 @@ def get_notification_channel_id(notify_channel, profile="telemetry"): "email": notify_channel, } response = requests.post( - post_url, data=salt.utils.json.dumps(data), headers=auth + post_url, data=salt.utils.json.dumps(data), headers=auth, timeout=120 ) if response.status_code == 200: log.info( @@ -233,6 +233,7 @@ def get_alarms(deployment_id, profile="telemetry"): response = requests.get( _get_telemetry_base(profile) + f"/alerts?deployment={deployment_id}", headers=auth, + timeout=120, ) except requests.exceptions.RequestException as e: log.error(str(e)) @@ -290,7 +291,10 @@ def create_alarm(deployment_id, metric_name, data, api_key=None, profile="teleme try: response = requests.post( - request_uri, data=salt.utils.json.dumps(post_body), headers=auth + request_uri, + data=salt.utils.json.dumps(post_body), + headers=auth, + timeout=120, ) except requests.exceptions.RequestException as e: # TODO: May be we should retry? @@ -361,7 +365,10 @@ def update_alarm(deployment_id, metric_name, data, api_key=None, profile="teleme try: response = requests.put( - request_uri, data=salt.utils.json.dumps(post_body), headers=auth + request_uri, + data=salt.utils.json.dumps(post_body), + headers=auth, + timeout=120, ) except requests.exceptions.RequestException as e: log.error("Update failed: %s", e) @@ -426,7 +433,7 @@ def delete_alarms( delete_url = _get_telemetry_base(profile) + f"/alerts/{id}" try: - response = requests.delete(delete_url, headers=auth) + response = requests.delete(delete_url, headers=auth, timeout=120) if metric_name: log.debug( "updating cache and delete %s key from %s", diff --git a/salt/modules/tomcat.py b/salt/modules/tomcat.py index 1a15fa83627..b1ff4a1364d 100644 --- a/salt/modules/tomcat.py +++ b/salt/modules/tomcat.py @@ -630,17 +630,14 @@ def passwd(passwd, user="", alg="sha1", realm=None): salt '*' tomcat.passwd secret tomcat sha1 salt '*' tomcat.passwd secret tomcat sha1 'Protected Realm' """ + # pylint: disable=no-value-for-parameter + # we call the first parameter the same as the function! + # Shouldn't it be SHA265 instead of SHA1? - digest = hasattr(hashlib, alg) and getattr(hashlib, alg) or None - if digest: + digest = getattr(hashlib, alg, None) + if digest is not None: if realm: - digest.update( - "{}:{}:{}".format( - user, - realm, - passwd, - ) - ) + digest.update(f"{user}:{realm}:{passwd}") else: digest.update(passwd) diff --git a/salt/modules/uptime.py b/salt/modules/uptime.py index e3549cc305e..702e01ec51a 100644 --- a/salt/modules/uptime.py +++ b/salt/modules/uptime.py @@ -48,7 +48,7 @@ def create(name, **params): application_url = _get_application_url() log.debug("[uptime] trying PUT request") params.update(url=name) - req = requests.put(f"{application_url}/api/checks", data=params) + req = requests.put(f"{application_url}/api/checks", data=params, timeout=120) if not req.ok: raise CommandExecutionError(f"request to uptime failed : {req.reason}") log.debug("[uptime] PUT request successful") @@ -71,9 +71,9 @@ def delete(name): raise CommandExecutionError(msg) application_url = _get_application_url() log.debug("[uptime] trying DELETE request") - jcontent = requests.get(f"{application_url}/api/checks").json() + jcontent = requests.get(f"{application_url}/api/checks", timeout=120).json() url_id = [x["_id"] for x in jcontent if x["url"] == name][0] - req = requests.delete(f"{application_url}/api/checks/{url_id}") + req = requests.delete(f"{application_url}/api/checks/{url_id}", timeout=120) if not req.ok: raise CommandExecutionError(f"request to uptime failed : {req.reason}") log.debug("[uptime] DELETE request successful") @@ -105,7 +105,7 @@ def checks_list(): """ application_url = _get_application_url() log.debug("[uptime] get checks") - jcontent = requests.get(f"{application_url}/api/checks").json() + jcontent = requests.get(f"{application_url}/api/checks", timeout=120).json() return [x["url"] for x in jcontent] diff --git a/salt/modules/virt.py b/salt/modules/virt.py index d7d7cfe65a6..f5c58f235a0 100644 --- a/salt/modules/virt.py +++ b/salt/modules/virt.py @@ -525,12 +525,15 @@ def _get_disks(conn, dom): "disk size": vol_info[2], } + _nodes = elem.findall( # pylint: disable=cell-var-from-loop + ".//backingStore[source]" + ) backing_files = [ { "file": node.find("source").get("file"), "file format": node.find("format").get("type"), } - for node in elem.findall(".//backingStore[source]") + for node in _nodes ] if backing_files: @@ -569,7 +572,7 @@ def _get_disks(conn, dom): disks[target.get("dev")] = {"file": qemu_target, "zfs": True} continue - if qemu_target in all_volumes.keys(): + if qemu_target in all_volumes: # If the qemu_target is a known path, output a volume volume = all_volumes[qemu_target] qemu_target, extra_properties = _get_disk_volume_data( @@ -604,7 +607,7 @@ def _get_disks(conn, dom): elif disk_type == "block": qemu_target = source.get("dev", "") # If the qemu_target is a known path, output a volume - if qemu_target in all_volumes.keys(): + if qemu_target in all_volumes: volume = all_volumes[qemu_target] qemu_target, extra_properties = _get_disk_volume_data( volume["pool"], volume["name"] @@ -1008,7 +1011,7 @@ def _gen_xml( efi_value = context["boot"].get("efi", None) if boot else None if efi_value is True: context["boot"]["os_attrib"] = "firmware='efi'" - elif efi_value is not None and type(efi_value) != bool: + elif efi_value is not None and not isinstance(efi_value, bool): raise SaltInvocationError("Invalid efi value") if os_type == "xen": @@ -1958,7 +1961,7 @@ def _handle_efi_param(boot, desc): return True # check the case that loader tag might be present. This happens after the vm ran - elif type(efi_value) == bool and os_attrib == {}: + elif isinstance(efi_value, bool) and os_attrib == {}: if efi_value is True and parent_tag.find("loader") is None: parent_tag.set("firmware", "efi") return True @@ -1966,7 +1969,7 @@ def _handle_efi_param(boot, desc): parent_tag.remove(parent_tag.find("loader")) parent_tag.remove(parent_tag.find("nvram")) return True - elif type(efi_value) != bool: + elif not isinstance(efi_value, bool): raise SaltInvocationError("Invalid efi value") return False diff --git a/salt/modules/win_iis.py b/salt/modules/win_iis.py index 04d2f35d0ba..b20cc2fc7bc 100644 --- a/salt/modules/win_iis.py +++ b/salt/modules/win_iis.py @@ -1455,7 +1455,7 @@ def set_container_setting(name, container, settings): # Map to numeric to support server 2008 if ( setting == "processModel.identityType" - and settings[setting] in identityType_map2numeric.keys() + and settings[setting] in identityType_map2numeric ): value = identityType_map2numeric[settings[setting]] @@ -1489,7 +1489,7 @@ def set_container_setting(name, container, settings): # map identity type from numeric to string for comparing if ( setting == "processModel.identityType" - and settings[setting] in identityType_map2string.keys() + and settings[setting] in identityType_map2string ): settings[setting] = identityType_map2string[settings[setting]] diff --git a/salt/modules/win_lgpo.py b/salt/modules/win_lgpo.py index 71a875c5638..02f8bb90703 100644 --- a/salt/modules/win_lgpo.py +++ b/salt/modules/win_lgpo.py @@ -8682,8 +8682,8 @@ def get_policy_info(policy_name, policy_class, adml_language="en-US"): } policy_class = policy_class.title() policy_data = _policy_info() - if policy_class not in policy_data.policies.keys(): - policy_classes = ", ".join(policy_data.policies.keys()) + if policy_class not in policy_data.policies: + policy_classes = ", ".join(policy_data.policies) ret["message"] = ( 'The requested policy class "{}" is invalid, ' "policy_class should be one of: {}" @@ -9707,7 +9707,7 @@ def get_policy( raise SaltInvocationError("policy_class must be defined") policy_class = policy_class.title() policy_data = _policy_info() - if policy_class not in policy_data.policies.keys(): + if policy_class not in policy_data.policies: policy_classes = ", ".join(policy_data.policies.keys()) raise CommandExecutionError( 'The requested policy class "{}" is invalid, policy_class should ' diff --git a/salt/modules/win_lgpo_reg.py b/salt/modules/win_lgpo_reg.py index da0fe393730..6789b034a88 100644 --- a/salt/modules/win_lgpo_reg.py +++ b/salt/modules/win_lgpo_reg.py @@ -374,16 +374,16 @@ def set_value( if found_key: if found_name: if "**del." in found_name: - log.debug(f"LGPO_REG Mod: Found disabled name: {found_name}") + log.debug("LGPO_REG Mod: Found disabled name: %s", found_name) pol_data[found_key][v_name] = pol_data[found_key].pop(found_name) found_name = v_name - log.debug(f"LGPO_REG Mod: Updating value: {found_name}") + log.debug("LGPO_REG Mod: Updating value: %s", found_name) pol_data[found_key][found_name] = {"data": v_data, "type": v_type} else: - log.debug(f"LGPO_REG Mod: Setting new value: {found_name}") + log.debug("LGPO_REG Mod: Setting new value: %s", found_name) pol_data[found_key][v_name] = {"data": v_data, "type": v_type} else: - log.debug(f"LGPO_REG Mod: Adding new key and value: {found_name}") + log.debug("LGPO_REG Mod: Adding new key and value: %s", found_name) pol_data[key] = {v_name: {"data": v_data, "type": v_type}} success = True @@ -463,20 +463,22 @@ def disable_value(key, v_name, policy_class="machine"): if found_key: if found_name: if "**del." in found_name: - log.debug(f"LGPO_REG Mod: Already disabled: {v_name}") + log.debug("LGPO_REG Mod: Already disabled: %s", v_name) return None - log.debug(f"LGPO_REG Mod: Disabling value name: {v_name}") + log.debug("LGPO_REG Mod: Disabling value name: %s", v_name) pol_data[found_key].pop(found_name) found_name = f"**del.{found_name}" pol_data[found_key][found_name] = {"data": " ", "type": "REG_SZ"} else: - log.debug(f"LGPO_REG Mod: Setting new disabled value name: {v_name}") + log.debug("LGPO_REG Mod: Setting new disabled value name: %s", v_name) pol_data[found_key][f"**del.{v_name}"] = { "data": " ", "type": "REG_SZ", } else: - log.debug(f"LGPO_REG Mod: Adding new key and disabled value name: {found_name}") + log.debug( + "LGPO_REG Mod: Adding new key and disabled value name: %s", found_name + ) pol_data[key] = {f"**del.{v_name}": {"data": " ", "type": "REG_SZ"}} success = True @@ -554,16 +556,16 @@ def delete_value(key, v_name, policy_class="Machine"): if found_key: if found_name: - log.debug(f"LGPO_REG Mod: Removing value name: {found_name}") + log.debug("LGPO_REG Mod: Removing value name: %s", found_name) pol_data[found_key].pop(found_name) else: - log.debug(f"LGPO_REG Mod: Value name not found: {v_name}") + log.debug("LGPO_REG Mod: Value name not found: %s", v_name) return None if len(pol_data[found_key]) == 0: - log.debug(f"LGPO_REG Mod: Removing empty key: {found_key}") + log.debug("LGPO_REG Mod: Removing empty key: %s", found_key) pol_data.pop(found_key) else: - log.debug(f"LGPO_REG Mod: Key not found: {key}") + log.debug("LGPO_REG Mod: Key not found: %s", key) return None success = True diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index 3b9224c4815..aff40b3d54d 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -1647,7 +1647,7 @@ def install(name=None, refresh=False, pkgs=None, **kwargs): # single files if cache_dir and installer.startswith("salt:"): path, _ = os.path.split(installer) - log.debug(f"PKG: Caching directory: {path}") + log.debug("PKG: Caching directory: %s", path) try: __salt__["cp.cache_dir"]( path=path, @@ -1664,7 +1664,7 @@ def install(name=None, refresh=False, pkgs=None, **kwargs): # Check to see if the cache_file is cached... if passed if cache_file and cache_file.startswith("salt:"): cache_file_hash = __salt__["cp.hash_file"](cache_file, saltenv) - log.debug(f"PKG: Caching file: {cache_file}") + log.debug("PKG: Caching file: %s", cache_file) try: cached_file = __salt__["cp.cache_file"]( cache_file, @@ -1694,7 +1694,7 @@ def install(name=None, refresh=False, pkgs=None, **kwargs): # file if the source_hash doesn't match, which only works on # files hosted on "salt://". If the http/https url supports # etag, it should also verify that information before caching - log.debug(f"PKG: Caching file: {installer}") + log.debug("PKG: Caching file: %s", installer) try: cached_pkg = __salt__["cp.cache_file"]( installer, @@ -2091,7 +2091,7 @@ def remove(name=None, pkgs=None, **kwargs): if cache_dir and uninstaller.startswith("salt:"): path, _ = os.path.split(uninstaller) - log.debug(f"PKG: Caching dir: {path}") + log.debug("PKG: Caching dir: %s", path) try: __salt__["cp.cache_dir"]( path=path, @@ -2115,7 +2115,7 @@ def remove(name=None, pkgs=None, **kwargs): # only works on files hosted on "salt://". If the http/https # url supports etag, it should also verify that information # before caching - log.debug(f"PKG: Caching file: {uninstaller}") + log.debug("PKG: Caching file: %s", uninstaller) try: cached_pkg = __salt__["cp.cache_file"]( uninstaller, diff --git a/salt/modules/win_pki.py b/salt/modules/win_pki.py index d7129bcf2a1..e004f0bc9e8 100644 --- a/salt/modules/win_pki.py +++ b/salt/modules/win_pki.py @@ -124,7 +124,7 @@ def get_stores(): salt '*' win_pki.get_stores """ ret = dict() - cmd = r"Get-ChildItem -Path 'Cert:\' | " r"Select-Object LocationName, StoreNames" + cmd = r"Get-ChildItem -Path 'Cert:\' | Select-Object LocationName, StoreNames" items = _cmd_run(cmd=cmd, as_json=True) diff --git a/salt/modules/win_shortcut.py b/salt/modules/win_shortcut.py index 90d1ae52f63..f3ae9d5942e 100644 --- a/salt/modules/win_shortcut.py +++ b/salt/modules/win_shortcut.py @@ -83,7 +83,9 @@ def get(path): # This will load the existing shortcut with salt.utils.winapi.Com(): - shell = win32com.client.Dispatch("WScript.Shell") + shell = win32com.client.Dispatch( # pylint: disable=used-before-assignment + "WScript.Shell" + ) shortcut = shell.CreateShortcut(path) arguments = "" diff --git a/salt/modules/win_status.py b/salt/modules/win_status.py index ee789c4363b..8b349a79bcc 100644 --- a/salt/modules/win_status.py +++ b/salt/modules/win_status.py @@ -148,9 +148,6 @@ def __virtual__(): if not HAS_PSUTIL: return False, "win_status.py: Requires psutil" - # Namespace modules from `status.py` - global ping_master, time_ - return __virtualname__ @@ -526,9 +523,7 @@ def master(master=None, connected=True): """ remotes = set() try: - data = subprocess.check_output( - ["netstat", "-n", "-p", "TCP"] - ) # pylint: disable=minimum-python-version + data = subprocess.check_output(["netstat", "-n", "-p", "TCP"]) except subprocess.CalledProcessError: log.error("Failed netstat") raise diff --git a/salt/modules/win_task.py b/salt/modules/win_task.py index 2151b663ba3..2b23e381bc0 100644 --- a/salt/modules/win_task.py +++ b/salt/modules/win_task.py @@ -245,7 +245,7 @@ def _reverse_lookup(dictionary, value): """ value_index = -1 for idx, dict_value in enumerate(dictionary.values()): - if type(dict_value) == list: + if isinstance(dict_value, list): if value in dict_value: value_index = idx break @@ -269,7 +269,7 @@ def _lookup_first(dictionary, key): :rtype: str """ value = dictionary[key] - if type(value) == list: + if isinstance(value, list): return value[0] else: return value diff --git a/salt/modules/x509_v2.py b/salt/modules/x509_v2.py index 1e20c088d59..2a4383d04f9 100644 --- a/salt/modules/x509_v2.py +++ b/salt/modules/x509_v2.py @@ -1943,7 +1943,7 @@ def _query_remote(ca_server, signing_policy, kwargs, get_signing_policy_only=Fal ) result = result[next(iter(result))] if not isinstance(result, dict) or "data" not in result: - log.error(f"Received invalid return value from ca_server: {result}") + log.error("Received invalid return value from ca_server: %s", result) raise CommandExecutionError( "Received invalid return value from ca_server. See minion log for details" ) diff --git a/salt/modules/xapi_virt.py b/salt/modules/xapi_virt.py index 89772a302cd..2d03d231ffb 100644 --- a/salt/modules/xapi_virt.py +++ b/salt/modules/xapi_virt.py @@ -17,6 +17,7 @@ Useful documentation: """ import contextlib +import importlib import os import sys @@ -26,15 +27,6 @@ import salt.utils.path import salt.utils.stringutils from salt.exceptions import CommandExecutionError -try: - import importlib # pylint: disable=minimum-python-version - - HAS_IMPORTLIB = True -except ImportError: - # Python < 2.7 does not have importlib - HAS_IMPORTLIB = False - - # Define the module's virtual name __virtualname__ = "virt" @@ -55,9 +47,7 @@ def _check_xenapi(): sys.path.append(xapipath) try: - if HAS_IMPORTLIB: - return importlib.import_module("xen.xm.XenAPI") - return __import__("xen.xm.XenAPI").xm.XenAPI + return importlib.import_module("xen.xm.XenAPI") except (ImportError, AttributeError): return False diff --git a/salt/modules/xfs.py b/salt/modules/xfs.py index 16c6e85a572..c47201262d0 100644 --- a/salt/modules/xfs.py +++ b/salt/modules/xfs.py @@ -319,7 +319,10 @@ def _blkid_output(out): """ Parse blkid output. """ - flt = lambda data: [el for el in data if el.strip()] + + def flt(data): + return [el for el in data if el.strip()] + data = {} for dev_meta in flt(out.split("\n\n")): dev = {} @@ -439,11 +442,13 @@ def mkfs( salt '*' xfs.mkfs /dev/sda1 dso='su=32k,sw=6' lso='logdev=/dev/sda2,size=10000b' """ - getopts = lambda args: dict( - (args and ("=" in args) and args or None) - and [kw.split("=") for kw in args.split(",")] - or [] - ) + def getopts(args): + return dict( + (args and ("=" in args) and args or None) + and [kw.split("=") for kw in args.split(",")] + or [] + ) + cmd = ["mkfs.xfs"] if label: cmd.append("-L") diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index 0ca3e9dc809..01c0726d49f 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -395,7 +395,7 @@ def _get_yum_config_value(name, strict_config=True): Look for a specific config variable and return its value """ conf = _get_yum_config(strict_config) - if name in conf.keys(): + if name in conf: return conf.get(name) return None @@ -3119,7 +3119,9 @@ def mod_repo(repo, basedir=None, **kwargs): if key in filerepos[repo].copy().keys(): del filerepos[repo][key] - _bool_to_str = lambda x: "1" if x else "0" + def _bool_to_str(x): + return "1" if x else "0" + # Old file or new, write out the repos(s) filerepos[repo].update(repo_opts) content = header diff --git a/salt/modules/zcbuildout.py b/salt/modules/zcbuildout.py index c5c32dac2ef..6a908b0c258 100644 --- a/salt/modules/zcbuildout.py +++ b/salt/modules/zcbuildout.py @@ -286,7 +286,7 @@ def _Popen( directory = os.path.abspath(directory) if isinstance(command, list): command = " ".join(command) - LOG.debug(f"Running {command}") # pylint: disable=str-format-in-logging + LOG.debug(f"Running {command}") if not loglevel: loglevel = "debug" ret = __salt__["cmd.run_all"]( @@ -498,7 +498,7 @@ def upgrade_bootstrap( else: buildout_ver = _get_buildout_ver(directory) booturl = _get_bootstrap_url(directory) - LOG.debug(f"Using {booturl}") # pylint: disable=str-format-in-logging + LOG.debug(f"Using {booturl}") # try to download an up-to-date bootstrap # set defaulttimeout # and add possible content @@ -791,9 +791,7 @@ def run_buildout( cmds, outputs = [], [] if parts: for part in parts: - LOG.info( - f"Installing single part: {part}" - ) # pylint: disable=str-format-in-logging + LOG.info(f"Installing single part: {part}") cmd = "{} -c {} {} install {}".format(bcmd, config, " ".join(argv), part) cmds.append(cmd) outputs.append( @@ -959,9 +957,7 @@ def buildout( salt '*' buildout.buildout /srv/mybuildout """ - LOG.info( - f"Running buildout in {directory} ({config})" - ) # pylint: disable=str-format-in-logging + LOG.info(f"Running buildout in {directory} ({config})") boot_ret = bootstrap( directory, config=config, diff --git a/salt/netapi/rest_cherrypy/__init__.py b/salt/netapi/rest_cherrypy/__init__.py index fbc85c9ff60..4580c6dc81b 100644 --- a/salt/netapi/rest_cherrypy/__init__.py +++ b/salt/netapi/rest_cherrypy/__init__.py @@ -28,7 +28,7 @@ cpy_min = "3.2.2" def __virtual__(): - short_name = __name__.rsplit(".")[-1] + short_name = __name__.rsplit(".", maxsplit=1)[-1] mod_opts = __opts__.get(short_name, {}) if mod_opts: diff --git a/salt/netapi/rest_cherrypy/app.py b/salt/netapi/rest_cherrypy/app.py index 56a4859d431..57443796ffe 100644 --- a/salt/netapi/rest_cherrypy/app.py +++ b/salt/netapi/rest_cherrypy/app.py @@ -711,9 +711,9 @@ def salt_api_acl_tool(username, request): :param request: Cherrypy request to check against the API. :type request: cherrypy.request """ - failure_str = "[api_acl] Authentication failed for " "user %s from IP %s" + failure_str = "[api_acl] Authentication failed for user %s from IP %s" success_str = "[api_acl] Authentication successful for user %s from IP %s" - pass_str = "[api_acl] Authentication not checked for " "user %s from IP %s" + pass_str = "[api_acl] Authentication not checked for user %s from IP %s" acl = None # Salt Configuration @@ -777,7 +777,7 @@ def salt_auth_tool(): Redirect all unauthenticated requests to the login page """ # Redirect to the login page if the session hasn't been authed - if "token" not in cherrypy.session: # pylint: disable=W8601 + if "token" not in cherrypy.session: raise cherrypy.HTTPError(401) # Session is authenticated; inform caches @@ -1147,7 +1147,7 @@ for hook, tool_list in tools_config.items(): for idx, tool_config in enumerate(tool_list): tool_name, tool_fn = tool_config setattr( - cherrypy.tools, tool_name, cherrypy.Tool(hook, tool_fn, priority=(50 + idx)) + cherrypy.tools, tool_name, cherrypy.Tool(hook, tool_fn, priority=50 + idx) ) diff --git a/salt/netapi/rest_tornado/saltnado.py b/salt/netapi/rest_tornado/saltnado.py index f657572c6ad..50857e60af2 100644 --- a/salt/netapi/rest_tornado/saltnado.py +++ b/salt/netapi/rest_tornado/saltnado.py @@ -332,12 +332,12 @@ class EventListener: Get an event (asynchronous of course) return a future that will get it later """ future = Future() + _loop = tornado.ioloop.IOLoop.current() + assert _loop if callback is not None: def handle_future(future): - tornado.ioloop.IOLoop.current().add_callback( - callback, future - ) # pylint: disable=E1102 + _loop.add_callback(callback, future) # pylint: disable=not-callable future.add_done_callback(handle_future) # add this tag and future to the callbacks @@ -345,7 +345,7 @@ class EventListener: self.request_map[request].append((tag, matcher, future)) if timeout: - timeout_future = tornado.ioloop.IOLoop.current().call_later( + timeout_future = _loop.call_later( timeout, self._timeout_future, tag, matcher, future ) self.timeout_map[future] = timeout_future diff --git a/salt/output/pony.py b/salt/output/pony.py index e8cc866cff2..60e47ba281a 100644 --- a/salt/output/pony.py +++ b/salt/output/pony.py @@ -65,6 +65,4 @@ def output(data, **kwargs): # pylint: disable=unused-argument Mane function """ high_out = __salt__["highstate"](data) - return subprocess.check_output( - ["ponysay", salt.utils.data.decode(high_out)] - ) # pylint: disable=E0598 + return subprocess.check_output(["ponysay", salt.utils.data.decode(high_out)]) diff --git a/salt/payload.py b/salt/payload.py index 46f3e593921..dc068bce2ca 100644 --- a/salt/payload.py +++ b/salt/payload.py @@ -84,26 +84,15 @@ def loads(msg, encoding=None, raw=False): gc.disable() # performance optimization for msgpack loads_kwargs = {"use_list": True, "ext_hook": ext_type_decoder} - if salt.utils.msgpack.version >= (0, 4, 0): - # msgpack only supports 'encoding' starting in 0.4.0. - # Due to this, if we don't need it, don't pass it at all so - # that under Python 2 we can still work with older versions - # of msgpack. - if salt.utils.msgpack.version >= (0, 5, 2): - if encoding is None: - loads_kwargs["raw"] = True - else: - loads_kwargs["raw"] = False - else: - loads_kwargs["encoding"] = encoding - try: - ret = salt.utils.msgpack.unpackb(msg, **loads_kwargs) - except UnicodeDecodeError: - # msg contains binary data - loads_kwargs.pop("raw", None) - loads_kwargs.pop("encoding", None) - ret = salt.utils.msgpack.loads(msg, **loads_kwargs) + if encoding is None: + loads_kwargs["raw"] = True else: + loads_kwargs["raw"] = False + try: + ret = salt.utils.msgpack.unpackb(msg, **loads_kwargs) + except UnicodeDecodeError: + # msg contains binary data + loads_kwargs.pop("raw", None) ret = salt.utils.msgpack.loads(msg, **loads_kwargs) if encoding is None and not raw: ret = salt.transport.frame.decode_embedded_strs(ret) diff --git a/salt/pillar/__init__.py b/salt/pillar/__init__.py index 7c5bb0c246e..271e7509351 100644 --- a/salt/pillar/__init__.py +++ b/salt/pillar/__init__.py @@ -260,8 +260,8 @@ class AsyncRemotePillar(RemotePillarMixin): load["clean_cache"] = self.clean_cache if self.ext: load["ext"] = self.ext + start = time.monotonic() try: - start = time.monotonic() ret_pillar = yield self.channel.crypted_transfer_decode_dictentry( load, dictkey="pillar", @@ -358,8 +358,8 @@ class RemotePillar(RemotePillarMixin): if self.ext: load["ext"] = self.ext + start = time.monotonic() try: - start = time.monotonic() ret_pillar = self.channel.crypted_transfer_decode_dictentry( load, dictkey="pillar", @@ -1221,7 +1221,7 @@ class Pillar: errors.append( "Failed to load ext_pillar {}: {}".format( key, - exc.__str__(), + exc, ) ) log.error( diff --git a/salt/pillar/foreman.py b/salt/pillar/foreman.py index 62ae03072f2..298aae1ef20 100644 --- a/salt/pillar/foreman.py +++ b/salt/pillar/foreman.py @@ -111,6 +111,7 @@ def ext_pillar(minion_id, pillar, key=None, only=()): # pylint: disable=W0613 headers=headers, verify=verify, cert=(certfile, keyfile), + timeout=120, ) result = resp.json() diff --git a/salt/pillar/pepa.py b/salt/pillar/pepa.py index 3be4a4bea62..842a14d49a3 100644 --- a/salt/pillar/pepa.py +++ b/salt/pillar/pepa.py @@ -291,7 +291,7 @@ except ImportError: # Only used when called from a terminal log = None if __name__ == "__main__": - import argparse # pylint: disable=minimum-python-version + import argparse parser = argparse.ArgumentParser() parser.add_argument("hostname", help="Hostname") @@ -611,7 +611,7 @@ if __name__ == "__main__": log.info("Authenticate REST API") auth = {"username": username, "password": password, "eauth": "pam"} - request = requests.post(args.url + "/login", auth) + request = requests.post(args.url + "/login", auth, timeout=120) if not request.ok: raise RuntimeError( @@ -623,7 +623,9 @@ if __name__ == "__main__": log.info("Request Grains from REST API") headers = {"X-Auth-Token": token, "Accept": "application/json"} - request = requests.get(args.url + "/minions/" + args.hostname, headers=headers) + request = requests.get( + args.url + "/minions/" + args.hostname, headers=headers, timeout=120 + ) result = request.json().get("return", [{}])[0] if args.hostname not in result: @@ -651,8 +653,8 @@ if __name__ == "__main__": if __opts__["pepa_validate"]: validate(result, __opts__["ext_pillar"][loc]["pepa"]["resource"]) + orig_ignore = salt.utils.yaml.SafeOrderedDumper.ignore_aliases try: - orig_ignore = salt.utils.yaml.SafeOrderedDumper.ignore_aliases salt.utils.yaml.SafeOrderedDumper.ignore_aliases = lambda x, y: True def _print_result(result): diff --git a/salt/pillar/vmware_pillar.py b/salt/pillar/vmware_pillar.py index cb93efed0da..41fd89a771d 100644 --- a/salt/pillar/vmware_pillar.py +++ b/salt/pillar/vmware_pillar.py @@ -483,5 +483,5 @@ def _serializer(obj): if isinstance(obj, datetime.datetime): if obj.utcoffset() is not None: obj = obj - obj.utcoffset() - return obj.__str__() + return str(obj) return obj diff --git a/salt/platform/win.py b/salt/platform/win.py index 0483e016d9e..ec63dbe319f 100644 --- a/salt/platform/win.py +++ b/salt/platform/win.py @@ -15,6 +15,7 @@ import logging import os from ctypes import wintypes +# pylint: disable=3rd-party-module-not-gated import ntsecuritycon import psutil import win32api @@ -23,6 +24,8 @@ import win32process import win32security import win32service +# pylint: enable=3rd-party-module-not-gated + # Set up logging log = logging.getLogger(__name__) @@ -398,7 +401,7 @@ class ContiguousUnicode(ctypes.Structure): @classmethod def from_address_copy(cls, address, size=None): - x = ctypes.Structure.__new__(cls) + x = ctypes.Structure.__new__(cls) # pylint: disable=no-value-for-parameter if size is not None: ctypes.resize(x, size) ctypes.memmove(ctypes.byref(x), address, ctypes.sizeof(x)) diff --git a/salt/proxy/dummy.py b/salt/proxy/dummy.py index d1238c9c4eb..12d71104a0a 100644 --- a/salt/proxy/dummy.py +++ b/salt/proxy/dummy.py @@ -95,7 +95,7 @@ def init(opts): __context__["dummy_proxy"] = {"id": opts["id"]} log.debug("dummy proxy init() called...") with _loaded_state(opts) as state: - state["initialized"] = True + state["initialized"] = True # pylint: disable=unsupported-assignment-operation def initialized(): @@ -113,12 +113,12 @@ def grains(): Make up some grains """ with _loaded_state(__opts__) as state: - if "grains_cache" not in state: - state["grains_cache"] = { - "dummy_grain_1": "one", - "dummy_grain_2": "two", - "dummy_grain_3": "three", - } + # pylint: disable=unsupported-assignment-operation,unsupported-membership-test + state["grains_cache"] = { + "dummy_grain_1": "one", + "dummy_grain_2": "two", + "dummy_grain_3": "three", + } return state["grains_cache"] @@ -127,7 +127,7 @@ def grains_refresh(): Refresh the grains """ with _loaded_state(__opts__) as state: - if "grains_cache" in state: + if "grains_cache" in state: # pylint: disable=unsupported-membership-test state.pop("grains_cache") return grains() @@ -262,7 +262,7 @@ def shutdown(opts): """ log.debug("dummy proxy shutdown() called...") with _loaded_state(__opts__) as state: - if "filename" in state: + if "filename" in state: # pylint: disable=unsupported-membership-test os.unlink(state["filename"]) diff --git a/salt/proxy/philips_hue.py b/salt/proxy/philips_hue.py index da3ab572430..d3400e3f66a 100644 --- a/salt/proxy/philips_hue.py +++ b/salt/proxy/philips_hue.py @@ -175,7 +175,7 @@ def _get_devices(params): raise CommandExecutionError("Parameter ID is required.") return ( - type(params["id"]) == int + isinstance(params["id"], int) and [params["id"]] or [int(dev) for dev in params["id"].split(",")] ) diff --git a/salt/renderers/genshi.py b/salt/renderers/genshi.py index 62716fc2522..680da8bcbc7 100644 --- a/salt/renderers/genshi.py +++ b/salt/renderers/genshi.py @@ -3,7 +3,9 @@ Genshi Renderer for Salt """ try: - from genshi.template import MarkupTemplate, NewTextTemplate, OldTextTemplate + from genshi.template import MarkupTemplate # pylint: disable=no-name-in-module + from genshi.template import NewTextTemplate # pylint: disable=no-name-in-module + from genshi.template import OldTextTemplate # pylint: disable=no-name-in-module HAS_LIBS = True except ImportError: diff --git a/salt/renderers/stateconf.py b/salt/renderers/stateconf.py index 50b2ebb20c0..d487f2d4e67 100644 --- a/salt/renderers/stateconf.py +++ b/salt/renderers/stateconf.py @@ -66,7 +66,7 @@ STATE_FUNC = STATE_NAME = "" def __init__(opts): global STATE_NAME, STATE_FUNC STATE_FUNC = __opts__["stateconf_state_func"] - STATE_NAME = STATE_FUNC.split(".")[0] + STATE_NAME = STATE_FUNC.split(".", maxsplit=1)[0] MOD_BASENAME = os.path.basename(__file__) diff --git a/salt/returners/etcd_return.py b/salt/returners/etcd_return.py index fbac0e169df..fe1d1e4cf22 100644 --- a/salt/returners/etcd_return.py +++ b/salt/returners/etcd_return.py @@ -232,7 +232,7 @@ def get_fun(fun): client, path = _get_conn(__opts__) items = client.get("/".join((path, "minions")), recurse=True) for id, jid in items.items(): - id = str(id).split("/")[-1] + id = str(id).rsplit("/", maxsplit=1)[-1] efun = salt.utils.json.loads( client.get("/".join((path, "jobs", str(jid), id, "fun"))) ) @@ -251,7 +251,7 @@ def get_jids(): items = client.get("/".join((path, "jobs")), recurse=True) for key, value in items.items(): if isinstance(value, dict): # dict means directory - jid = str(key).split("/")[-1] + jid = str(key).rsplit("/", maxsplit=1)[-1] ret.append(jid) return ret @@ -265,7 +265,7 @@ def get_minions(): client, path = _get_conn(__opts__) items = client.get("/".join((path, "minions")), recurse=True) for id, _ in items.items(): - id = str(id).split("/")[-1] + id = str(id).rsplit("/", maxsplit=1)[-1] ret.append(id) return ret diff --git a/salt/returners/influxdb_return.py b/salt/returners/influxdb_return.py index 99aa32716c3..76fdc15b369 100644 --- a/salt/returners/influxdb_return.py +++ b/salt/returners/influxdb_return.py @@ -108,7 +108,9 @@ def _get_version(host, port, user, password): version = None # check the InfluxDB version via the HTTP API try: - result = requests.get(f"http://{host}:{port}/ping", auth=(user, password)) + result = requests.get( + f"http://{host}:{port}/ping", auth=(user, password), timeout=120 + ) if influxDBVersionHeader in result.headers: version = result.headers[influxDBVersionHeader] except Exception as ex: # pylint: disable=broad-except diff --git a/salt/returners/local_cache.py b/salt/returners/local_cache.py index 927502358a6..4f62de3a5a3 100644 --- a/salt/returners/local_cache.py +++ b/salt/returners/local_cache.py @@ -287,6 +287,7 @@ def get_load(jid): ret = {} load_p = os.path.join(jid_dir, LOAD_P) num_tries = 5 + exc = None for index in range(1, num_tries + 1): with salt.utils.files.fopen(load_p, "rb") as rfh: try: @@ -297,7 +298,8 @@ def get_load(jid): time.sleep(0.25) else: log.critical("Failed to unpack %s", load_p) - raise exc + if exc is not None: + raise exc if ret is None: ret = {} minions_cache = [os.path.join(jid_dir, MINIONS_P)] diff --git a/salt/returners/mysql.py b/salt/returners/mysql.py index 87f5e37fa46..6ad64bebb36 100644 --- a/salt/returners/mysql.py +++ b/salt/returners/mysql.py @@ -148,10 +148,6 @@ import salt.utils.data import salt.utils.job import salt.utils.json -# Let's not allow PyLint complain about string substitution -# pylint: disable=W1321,E1321 - - try: # Trying to import MySQLdb import MySQLdb diff --git a/salt/returners/pgjsonb.py b/salt/returners/pgjsonb.py index 5cfd1150172..86fd63b7441 100644 --- a/salt/returners/pgjsonb.py +++ b/salt/returners/pgjsonb.py @@ -170,10 +170,6 @@ import salt.returners import salt.utils.data import salt.utils.job -# Let's not allow PyLint complain about string substitution -# pylint: disable=W1321,E1321 - - try: import psycopg2 import psycopg2.extras diff --git a/salt/returners/splunk.py b/salt/returners/splunk.py index df3414bcacf..5e11a550e59 100644 --- a/salt/returners/splunk.py +++ b/salt/returners/splunk.py @@ -210,6 +210,7 @@ class http_event_collector: data=salt.utils.json.dumps(data), headers=headers, verify=self.verify_ssl, + timeout=120, ) # Print debug info if flag set diff --git a/salt/roster/cache.py b/salt/roster/cache.py index 57f096dde6b..8545418cc23 100644 --- a/salt/roster/cache.py +++ b/salt/roster/cache.py @@ -220,7 +220,7 @@ def _minion_lookup(minion_id, key, minion): try: net = ipaddress.ip_network(key, strict=True) except ValueError: - log.error("%s is an invalid CIDR network", net) + log.error("%s is an invalid CIDR network", key) return None for addr in addrs[net.version]: diff --git a/salt/runners/asam.py b/salt/runners/asam.py index ca80dcfdf78..372bc7dd742 100644 --- a/salt/runners/asam.py +++ b/salt/runners/asam.py @@ -146,7 +146,7 @@ def _get_asam_configuration(driver_url=""): def _make_post_request(url, data, auth, verify=True): - r = requests.post(url, data=data, auth=auth, verify=verify) + r = requests.post(url, data=data, auth=auth, verify=verify, timeout=120) if r.status_code != requests.codes.ok: r.raise_for_status() else: diff --git a/salt/runners/launchd.py b/salt/runners/launchd.py index cbbd22ae6ec..87184e5c66c 100644 --- a/salt/runners/launchd.py +++ b/salt/runners/launchd.py @@ -51,8 +51,8 @@ def write_launchd_plist(program): sys.stderr.write(f"Supported programs: '{supported_programs}'\n") sys.exit(-1) - return plist_sample_text.format( - program=program, - python=sys.executable, - script=os.path.join(os.path.dirname(sys.executable), program), - ) + return plist_sample_text.format( + program=program, + python=sys.executable, + script=os.path.join(os.path.dirname(sys.executable), program), + ) diff --git a/salt/runners/manage.py b/salt/runners/manage.py index 43f76e1d529..65b3455f53d 100644 --- a/salt/runners/manage.py +++ b/salt/runners/manage.py @@ -558,10 +558,7 @@ def safe_accept(target, tgt_type="glob"): print(message) print("") - __jid_event__.fire_event( - {"message": f"Accepted {len(ret):d} keys"}, - "progress", - ) + __jid_event__.fire_event({"message": f"Accepted {len(ret):d} keys"}, "progress") return ret, failures diff --git a/salt/runners/pkg.py b/salt/runners/pkg.py index 7d36caf2998..5abf574d063 100644 --- a/salt/runners/pkg.py +++ b/salt/runners/pkg.py @@ -39,7 +39,7 @@ def list_upgrades(jid, style="group", outputter="nested", ext_source=None): for minion in data: results = data[minion]["return"] for pkg, pkgver in results.items(): - if pkg not in pkgs.keys(): + if pkg not in pkgs: pkgs[pkg] = {pkgver: {"hosts": []}} if pkgver not in pkgs[pkg].keys(): diff --git a/salt/runners/state.py b/salt/runners/state.py index 3baf1b86346..e0e41a659ba 100644 --- a/salt/runners/state.py +++ b/salt/runners/state.py @@ -106,7 +106,9 @@ def orchestrate( orig_user = __opts__["user"] __opts__["user"] = __user__ log.debug( - f"changed opts user from original '{orig_user}' to global user '{__user__}'" + "changed opts user from original '%s' to global user '%s'", + orig_user, + __user__, ) except NameError: log.debug("unable to find global user __user__") diff --git a/salt/runners/vault.py b/salt/runners/vault.py index 27ef8cdf2b3..93a693f62fb 100644 --- a/salt/runners/vault.py +++ b/salt/runners/vault.py @@ -881,7 +881,7 @@ def clear_cache(master=True, minions=True): if minions: for minion in cache.list("minions"): if minions is True or (isinstance(minions, list) and minion in minions): - log.debug(f"Clearing master Vault cache for minion {minion}") + log.debug("Clearing master Vault cache for minion %s", minion) cache.flush(f"minions/{minion}/vault") return True diff --git a/salt/scripts.py b/salt/scripts.py index f322490f659..662104a7142 100644 --- a/salt/scripts.py +++ b/salt/scripts.py @@ -481,16 +481,14 @@ def salt_cloud(): """ The main function for salt-cloud """ - # Define 'salt' global so we may use it after ImportError. Otherwise, - # UnboundLocalError will be raised. - global salt # pylint: disable=W0602 - try: # Late-imports for CLI performance import salt.cloud import salt.cloud.cli except ImportError as e: # No salt cloud on Windows + import salt.defaults.exitcodes + log.error("Error importing salt cloud: %s", e) print("salt-cloud is not available in this system") sys.exit(salt.defaults.exitcodes.EX_UNAVAILABLE) diff --git a/salt/serializers/msgpack.py b/salt/serializers/msgpack.py index ac9eebb1e49..0b6dd96e802 100644 --- a/salt/serializers/msgpack.py +++ b/salt/serializers/msgpack.py @@ -5,108 +5,42 @@ Implements MsgPack serializer. """ -import copy import logging import salt.utils.msgpack from salt.serializers import DeserializationError, SerializationError log = logging.getLogger(__name__) + + +__all__ = ["deserialize", "serialize", "available"] + available = salt.utils.msgpack.HAS_MSGPACK -if not available: - - def _fail(): - raise RuntimeError("msgpack is not available") - - def _serialize(obj, **options): - _fail() - - def _deserialize(stream_or_string, **options): - _fail() - -elif salt.utils.msgpack.version >= (1, 0, 0): - - def _serialize(obj, **options): - try: - return salt.utils.msgpack.dumps(obj, **options) - except Exception as error: # pylint: disable=broad-except - raise SerializationError(error) - - def _deserialize(stream_or_string, **options): - try: - options.setdefault("use_list", True) - options.setdefault("raw", False) - return salt.utils.msgpack.loads(stream_or_string, **options) - except Exception as error: # pylint: disable=broad-except - raise DeserializationError(error) - -elif salt.utils.msgpack.version >= (0, 2, 0): - - def _serialize(obj, **options): - try: - return salt.utils.msgpack.dumps(obj, **options) - except Exception as error: # pylint: disable=broad-except - raise SerializationError(error) - - def _deserialize(stream_or_string, **options): - try: - options.setdefault("use_list", True) - options.setdefault("encoding", "utf-8") - return salt.utils.msgpack.loads(stream_or_string, **options) - except Exception as error: # pylint: disable=broad-except - raise DeserializationError(error) - -else: # msgpack.version < 0.2.0 - - def _encoder(obj): - """ - Since OrderedDict is identified as a dictionary, we can't make use of - msgpack custom types, we will need to convert by hand. - - This means iterating through all elements of dictionaries, lists and - tuples. - """ - if isinstance(obj, dict): - data = [(key, _encoder(value)) for key, value in obj.items()] - return dict(data) - elif isinstance(obj, (list, tuple)): - return [_encoder(value) for value in obj] - return copy.copy(obj) - - def _decoder(obj): - return obj - - def _serialize(obj, **options): - try: - obj = _encoder(obj) - return salt.utils.msgpack.dumps(obj, **options) - except Exception as error: # pylint: disable=broad-except - raise SerializationError(error) - - def _deserialize(stream_or_string, **options): - options.setdefault("use_list", True) - try: - obj = salt.utils.msgpack.loads(stream_or_string) - return _decoder(obj) - except Exception as error: # pylint: disable=broad-except - raise DeserializationError(error) - - -serialize = _serialize -deserialize = _deserialize - -serialize.__doc__ = """ +def serialize(obj, **options): + """ Serialize Python data to MsgPack. :param obj: the data structure to serialize :param options: options given to lower msgpack module. -""" + """ + try: + return salt.utils.msgpack.dumps(obj, **options) + except Exception as error: # pylint: disable=broad-except + raise SerializationError(error) -deserialize.__doc__ = """ + +def deserialize(stream_or_string, **options): + """ Deserialize any string of stream like object into a Python data structure. :param stream_or_string: stream or string to deserialize. :param options: options given to lower msgpack module. -""" + """ + try: + options.setdefault("use_list", True) + options.setdefault("raw", False) + return salt.utils.msgpack.loads(stream_or_string, **options) + except Exception as error: # pylint: disable=broad-except + raise DeserializationError(error) diff --git a/salt/serializers/yaml.py b/salt/serializers/yaml.py index bc6391618df..ae050376d6f 100644 --- a/salt/serializers/yaml.py +++ b/salt/serializers/yaml.py @@ -89,7 +89,7 @@ class EncryptedString(str): @staticmethod def yaml_dumper(dumper, data): - return dumper.represent_scalar(EncryptedString.yaml_tag, data.__str__()) + return dumper.represent_scalar(EncryptedString.yaml_tag, str(data)) class Loader(BaseLoader): # pylint: disable=W0232 diff --git a/salt/state.py b/salt/state.py index 92e6cbca385..e6add4d8b3c 100644 --- a/salt/state.py +++ b/salt/state.py @@ -128,11 +128,9 @@ STATE_INTERNAL_KEYWORDS = STATE_REQUISITE_KEYWORDS.union( ).union(STATE_RUNTIME_KEYWORDS) -def _odict_hashable(self): - return id(self) - - -OrderedDict.__hash__ = _odict_hashable +class HashableOrderedDict(OrderedDict): + def __hash__(self): + return id(self) def split_low_tag(tag): @@ -450,7 +448,7 @@ class Compiler: errors = [] if not isinstance(high, dict): errors.append("High data is not a dictionary and is invalid") - reqs = OrderedDict() + reqs = HashableOrderedDict() if not errors: for name, body in high.items(): try: @@ -1494,7 +1492,7 @@ class State: errors = [] if not isinstance(high, dict): errors.append("High data is not a dictionary and is invalid") - reqs = OrderedDict() + reqs = HashableOrderedDict() for name, body in high.items(): try: if name.startswith("__"): @@ -1574,7 +1572,7 @@ class State: # It is a list, verify that the members of the # list are all single key dicts. else: - reqs[name] = OrderedDict(state=state) + reqs[name] = HashableOrderedDict(state=state) for req in arg[argfirst]: if isinstance(req, str): req = {"id": req} @@ -1951,7 +1949,7 @@ class State: # Not a use requisite_in found = False if name not in extend: - extend[name] = OrderedDict() + extend[name] = HashableOrderedDict() if "." in _state: errors.append( "Invalid requisite in {}: {} for " @@ -2039,7 +2037,7 @@ class State: if key == "prereq_in": # Add prerequired to origin if id_ not in extend: - extend[id_] = OrderedDict() + extend[id_] = HashableOrderedDict() if state not in extend[id_]: extend[id_][state] = [] extend[id_][state].append( @@ -2052,7 +2050,7 @@ class State: ) for ext_id, _req_state in ext_ids: if ext_id not in extend: - extend[ext_id] = OrderedDict() + extend[ext_id] = HashableOrderedDict() if _req_state not in extend[ext_id]: extend[ext_id][_req_state] = [] extend[ext_id][_req_state].append( @@ -2070,7 +2068,7 @@ class State: continue ext_args = state_args(ext_id, _state, high) if ext_id not in extend: - extend[ext_id] = OrderedDict() + extend[ext_id] = HashableOrderedDict() if _req_state not in extend[ext_id]: extend[ext_id][_req_state] = [] ignore_args = req_in_all.union(ext_args) @@ -2099,7 +2097,7 @@ class State: continue loc_args = state_args(id_, state, high) if id_ not in extend: - extend[id_] = OrderedDict() + extend[id_] = HashableOrderedDict() if state not in extend[id_]: extend[id_][state] = [] ignore_args = req_in_all.union(loc_args) @@ -2119,7 +2117,7 @@ class State: continue found = False if name not in extend: - extend[name] = OrderedDict() + extend[name] = HashableOrderedDict() if _state not in extend[name]: extend[name][_state] = [] extend[name]["__env__"] = body["__env__"] @@ -2956,7 +2954,7 @@ class State: " with name [{}]".format(req_key, chunk["name"]) ) except TypeError: - # On Python 2, the above req_val, being an OrderedDict, will raise a KeyError, + # On Python 2, the above req_val, being an HashableOrderedDict, will raise a KeyError, # however on Python 3 it will raise a TypeError # This was found when running tests.unit.test_state.StateCompilerTestCase.test_render_error_on_invalid_requisite raise SaltRenderError( @@ -3078,11 +3076,13 @@ class State: self.opts.get("state_events", True) or fire_event ): if not self.opts.get("master_uri"): - ev_func = ( - lambda ret, tag, preload=None: salt.utils.event.get_master_event( + + def ev_func(ret, tag, preload=None): + with salt.utils.event.get_master_event( self.opts, self.opts["sock_dir"], listen=False - ).fire_event(ret, tag) - ) + ) as _evt: + _evt.fire_event(ret, tag) + else: ev_func = self.functions["event.fire_master"] @@ -3746,8 +3746,8 @@ class LazyAvailStates: def items(self): self._fill() ret = [] - for saltenv, states in self._avail.items(): - ret.append((saltenv, self.__getitem__(saltenv))) + for saltenv in self._avail: + ret.append((saltenv, self[saltenv])) return ret @@ -3764,7 +3764,7 @@ class BaseHighState: self.opts = self.__gen_opts(opts) self.iorder = 10000 self.avail = self.__gather_avail() - self.building_highstate = OrderedDict() + self.building_highstate = HashableOrderedDict() def __gather_avail(self): """ @@ -3998,10 +3998,10 @@ class BaseHighState: environment from the top file will be considered, and it too will be ignored if that environment was defined in the "base" top file. """ - top = DefaultOrderedDict(OrderedDict) + top = DefaultOrderedDict(HashableOrderedDict) # Check base env first as it is authoritative - base_tops = tops.pop("base", DefaultOrderedDict(OrderedDict)) + base_tops = tops.pop("base", DefaultOrderedDict(HashableOrderedDict)) for ctop in base_tops: for saltenv, targets in ctop.items(): if saltenv == "include": @@ -4054,7 +4054,7 @@ class BaseHighState: sections matching a given saltenv, which appear in a different saltenv's top file, will be ignored. """ - top = DefaultOrderedDict(OrderedDict) + top = DefaultOrderedDict(HashableOrderedDict) for cenv, ctops in tops.items(): if all([x == {} for x in ctops]): # No top file found in this env, check the default_top @@ -4135,7 +4135,7 @@ class BaseHighState: states.append(item) return match_type, states - top = DefaultOrderedDict(OrderedDict) + top = DefaultOrderedDict(HashableOrderedDict) for ctops in tops.values(): for ctop in ctops: for saltenv, targets in ctop.items(): @@ -4231,7 +4231,7 @@ class BaseHighState: Returns: {'saltenv': ['state1', 'state2', ...]} """ - matches = DefaultOrderedDict(OrderedDict) + matches = DefaultOrderedDict(HashableOrderedDict) # pylint: disable=cell-var-from-loop for saltenv, body in top.items(): if self.opts["saltenv"]: diff --git a/salt/states/archive.py b/salt/states/archive.py index 03dd9bdb441..f0614ae5dd3 100644 --- a/salt/states/archive.py +++ b/salt/states/archive.py @@ -119,7 +119,7 @@ def _update_checksum(path): log.warning( "Failed to update checksum for %s: %s", path, - exc.__str__(), + exc, exc_info=True, ) @@ -1196,7 +1196,7 @@ def extracted( ) except Exception as exc: # pylint: disable=broad-except msg = "Failed to cache {}: {}".format( - salt.utils.url.redact_http_basic_auth(source_match), exc.__str__() + salt.utils.url.redact_http_basic_auth(source_match), exc ) log.exception(msg) ret["comment"] = msg @@ -1352,7 +1352,7 @@ def extracted( else: ret["comment"] = ( "Failed to check for existence of if_missing path " - "({}): {}".format(if_missing, exc.__str__()) + "({}): {}".format(if_missing, exc) ) return ret else: @@ -1381,7 +1381,7 @@ def extracted( # that dir will raise an ENOTDIR OSError. So we # expect these and will only abort here if the # error code is something else. - ret["comment"] = exc.__str__() + ret["comment"] = str(exc) return ret if incorrect_type: @@ -1430,7 +1430,7 @@ def extracted( extraction_needed = True except OSError as exc: if exc.errno != errno.ENOENT: - errors.append(exc.__str__()) + errors.append(str(exc)) if errors: msg = ( "One or more paths existed by were the incorrect " @@ -1511,7 +1511,7 @@ def extracted( ret["changes"].setdefault("removed", []).append(full_path) except OSError as exc: if exc.errno != errno.ENOENT: - errors.append(exc.__str__()) + errors.append(str(exc)) if errors: msg = ( diff --git a/salt/states/boto3_route53.py b/salt/states/boto3_route53.py index 8494ecb4b12..7b1a5fdf3ab 100644 --- a/salt/states/boto3_route53.py +++ b/salt/states/boto3_route53.py @@ -62,7 +62,6 @@ passed in as a dict, or as a string to pull from pillars or minion config: # keep lint from choking # pylint: disable=W0106 -# pylint: disable=E1320 import logging @@ -72,7 +71,7 @@ import salt.utils.data import salt.utils.dictupdate from salt.exceptions import SaltInvocationError -log = logging.getLogger(__name__) # pylint: disable=W1699 +log = logging.getLogger(__name__) def __virtual__(): diff --git a/salt/states/docker_container.py b/salt/states/docker_container.py index 8008e8a5952..d5d4362b2d4 100644 --- a/salt/states/docker_container.py +++ b/salt/states/docker_container.py @@ -1692,7 +1692,7 @@ def running( if exc.info is not None: return _format_comments(ret, exc.info) else: - ret["comment"] = exc.__str__() + ret["comment"] = str(exc) return ret comments = [] @@ -1759,7 +1759,7 @@ def running( return _format_comments(ret, comments) except Exception as exc: # pylint: disable=broad-except ret["result"] = False - msg = exc.__str__() + msg = str(exc) if ( isinstance(exc, CommandExecutionError) and isinstance(exc.info, dict) @@ -1816,7 +1816,7 @@ def running( # of the network's subnet. An exception will be raised once # you try to start the container, however. ret["result"] = False - comments.append(exc.__str__()) + comments.append(str(exc)) return _format_comments(ret, comments) post_net_connect = __salt__["docker.inspect_container"](temp_container_name) @@ -1849,10 +1849,17 @@ def running( ) if not skip_comparison: + docker_version_info = __salt__["docker.version"]()["VersionInfo"] + if docker_version_info < (25, 0): + compare_containers_ignore = "Hostname" + else: + # With docker >= 25.0 we get a new value to compare, + # MacAddress, which we'll ignore for now. + compare_containers_ignore = "Hostname,MacAddress" container_changes = __salt__["docker.compare_containers"]( name, temp_container_name, - ignore="Hostname", + ignore=compare_containers_ignore, ) if container_changes: if _check_diff(container_changes): @@ -1945,7 +1952,7 @@ def running( ) disconnected = True except CommandExecutionError as exc: - errors.append(exc.__str__()) + errors.append(str(exc)) if net_name in networks: try: @@ -1954,7 +1961,7 @@ def running( ) connected = True except CommandExecutionError as exc: - errors.append(exc.__str__()) + errors.append(str(exc)) if disconnected: # We succeeded in disconnecting but failed # to reconnect. This can happen if the @@ -2201,7 +2208,7 @@ def run( if exc.info is not None: return _format_comments(ret, exc.info) else: - ret["comment"] = exc.__str__() + ret["comment"] = str(exc) return ret if __opts__["test"]: diff --git a/salt/states/docker_image.py b/salt/states/docker_image.py index 25a069cb399..3a0a77c10d1 100644 --- a/salt/states/docker_image.py +++ b/salt/states/docker_image.py @@ -253,7 +253,7 @@ def present( try: image_info = __salt__["docker.inspect_image"](full_image) except CommandExecutionError as exc: - msg = exc.__str__() + msg = str(exc) if "404" in msg: # Image not present image_info = None @@ -361,7 +361,7 @@ def present( try: __salt__["docker.inspect_image"](full_image) except CommandExecutionError as exc: - msg = exc.__str__() + msg = str(exc) if "404" not in msg: error = "Failed to inspect image '{}' after it was {}: {}".format( full_image, action, msg diff --git a/salt/states/docker_network.py b/salt/states/docker_network.py index 2710c69133b..4cdcfeccc02 100644 --- a/salt/states/docker_network.py +++ b/salt/states/docker_network.py @@ -529,7 +529,7 @@ def present( try: network = __salt__["docker.inspect_network"](name) except CommandExecutionError as exc: - msg = exc.__str__() + msg = str(exc) if "404" in msg: # Network not present network = None @@ -584,7 +584,7 @@ def present( **__utils__["args.clean_kwargs"](**kwargs), ) except Exception as exc: # pylint: disable=broad-except - ret["comment"] = exc.__str__() + ret["comment"] = str(exc) return ret # Separate out the IPAM config options and build the IPAM config dict @@ -613,7 +613,7 @@ def present( *ipam_pools, **ipam_kwargs ) except Exception as exc: # pylint: disable=broad-except - ret["comment"] = exc.__str__() + ret["comment"] = str(exc) return ret # We'll turn this off if we decide below that creating the network is not @@ -668,7 +668,7 @@ def present( ) except CommandExecutionError as exc: ret["comment"] = "Failed to create temp network for comparison: {}".format( - exc.__str__() + str(exc) ) return ret else: @@ -680,9 +680,7 @@ def present( try: temp_net_info = __salt__["docker.inspect_network"](temp_net_name) except CommandExecutionError as exc: - ret["comment"] = "Failed to inspect temp network: {}".format( - exc.__str__() - ) + ret["comment"] = f"Failed to inspect temp network: {str(exc)}" return ret else: temp_net_info["EnableIPv6"] = bool(enable_ipv6) @@ -696,9 +694,8 @@ def present( existing_pool_count = len(network["IPAM"]["Config"]) desired_pool_count = len(temp_net_info["IPAM"]["Config"]) - is_default_pool = lambda x: ( - True if sorted(x) == ["Gateway", "Subnet"] else False - ) + def is_default_pool(x): + return True if sorted(x) == ["Gateway", "Subnet"] else False if ( desired_pool_count == 0 @@ -782,9 +779,7 @@ def present( __salt__["docker.remove_network"](temp_net_name) except CommandExecutionError as exc: ret.setdefault("warnings", []).append( - "Failed to remove temp network '{}': {}.".format( - temp_net_name, exc.__str__() - ) + f"Failed to remove temp network '{temp_net_name}': {exc}." ) if create_network: @@ -809,9 +804,7 @@ def present( **kwargs, ) except Exception as exc: # pylint: disable=broad-except - ret["comment"] = "Failed to create network '{}': {}".format( - name, exc.__str__() - ) + ret["comment"] = f"Failed to create network '{name}': {exc}" return ret else: action = "recreated" if network is not None else "created" @@ -865,14 +858,14 @@ def present( ) except CommandExecutionError as exc: if not connect_kwargs: - errors.append(exc.__str__()) + errors.append(str(exc)) else: # We failed to reconnect with the container's old IP # configuration. Reconnect using automatic IP config. try: __salt__["docker.connect_container_to_network"](cid, name) except CommandExecutionError as exc: - errors.append(exc.__str__()) + errors.append(str(exc)) else: ret["changes"].setdefault( ( @@ -925,7 +918,7 @@ def absent(name): try: network = __salt__["docker.inspect_network"](name) except CommandExecutionError as exc: - msg = exc.__str__() + msg = str(exc) if "404" in msg: # Network not present network = None diff --git a/salt/states/environ.py b/salt/states/environ.py index ad574b10344..4c22a98da50 100644 --- a/salt/states/environ.py +++ b/salt/states/environ.py @@ -130,6 +130,7 @@ def setenv( r" Manager\Environment" ) + # pylint: disable=cell-var-from-loop out = __utils__["reg.read_value"]( permanent_hive, permanent_key, _norm_key(key) ) diff --git a/salt/states/file.py b/salt/states/file.py index 1eecd5bd673..21cf8cc75d4 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -566,6 +566,8 @@ def _gen_keep_files(name, require, walk_d=None): like directory or recurse has a clean. """ + walk_ret = set() + def _is_child(path, directory): """ Check whether ``path`` is child of ``directory`` @@ -1232,7 +1234,9 @@ def _shortcut_check( if os.path.isfile(name): with salt.utils.winapi.Com(): - shell = win32com.client.Dispatch("WScript.Shell") + shell = win32com.client.Dispatch( # pylint: disable=used-before-assignment + "WScript.Shell" + ) scut = shell.CreateShortcut(name) state_checks = [scut.TargetPath.lower() == target.lower()] if arguments is not None: @@ -9314,7 +9318,7 @@ def cached( name, saltenv=saltenv, source_hash=source_sum.get("hsum"), use_etag=use_etag ) except Exception as exc: # pylint: disable=broad-except - ret["comment"] = salt.utils.url.redact_http_basic_auth(exc.__str__()) + ret["comment"] = salt.utils.url.redact_http_basic_auth(str(exc)) return ret if not local_copy: @@ -9401,7 +9405,7 @@ def not_cached(name, saltenv="base"): try: os.remove(local_copy) except Exception as exc: # pylint: disable=broad-except - ret["comment"] = f"Failed to delete {local_copy}: {exc.__str__()}" + ret["comment"] = f"Failed to delete {local_copy}: {exc}" else: ret["result"] = True ret["changes"]["deleted"] = True diff --git a/salt/states/git.py b/salt/states/git.py index d4d91f0383f..d5127437208 100644 --- a/salt/states/git.py +++ b/salt/states/git.py @@ -685,7 +685,7 @@ def latest( name, https_user, https_pass, https_only=True ) except ValueError as exc: - return _fail(ret, exc.__str__()) + return _fail(ret, str(exc)) redacted_fetch_url = salt.utils.url.redact_http_basic_auth(desired_fetch_url) @@ -1063,6 +1063,7 @@ def latest( if (not revs_match and not update_head) and ( branch is None or branch == local_branch ): + # pylint: disable=used-before-assignment ret["comment"] = ( "{} is already present and local HEAD ({}) does not " "match, but update_head=False. HEAD has not been " @@ -1787,9 +1788,7 @@ def latest( ) log.error(msg, name) # Disable check for string substitution - return _fail( - ret, msg % "Repository", comments - ) # pylint: disable=E1321 + return _fail(ret, msg % "Repository", comments) else: if remote_rev_type == "tag" and rev not in __salt__[ "git.list_tags" @@ -2297,7 +2296,7 @@ def detached( name, https_user, https_pass, https_only=True ) except ValueError as exc: - return _fail(ret, exc.__str__()) + return _fail(ret, str(exc)) redacted_fetch_url = salt.utils.url.redact_http_basic_auth(desired_fetch_url) diff --git a/salt/states/grafana_dashboard.py b/salt/states/grafana_dashboard.py index 0e4538f8852..4a1dc14ae54 100644 --- a/salt/states/grafana_dashboard.py +++ b/salt/states/grafana_dashboard.py @@ -458,6 +458,7 @@ def _update(dashboard, profile): request_url, headers={"Authorization": "Bearer {}".format(profile.get("grafana_token"))}, json=payload, + timeout=120, ) return response.json() diff --git a/salt/states/grains.py b/salt/states/grains.py index d69a8779467..2dd675255c7 100644 --- a/salt/states/grains.py +++ b/salt/states/grains.py @@ -292,13 +292,13 @@ def list_absent(name, value, delimiter=DEFAULT_TARGET_DELIM): elif __opts__["test"]: ret["result"] = None comments.append(f"Value {val} in grain {name} is set to be deleted") - if "deleted" not in ret["changes"].keys(): + if "deleted" not in ret["changes"]: ret["changes"] = {"deleted": []} ret["changes"]["deleted"].append(val) elif val in grain: __salt__["grains.remove"](name, val) comments.append(f"Value {val} was deleted from grain {name}") - if "deleted" not in ret["changes"].keys(): + if "deleted" not in ret["changes"]: ret["changes"] = {"deleted": []} ret["changes"]["deleted"].append(val) ret["comment"] = "\n".join(comments) diff --git a/salt/states/ldap.py b/salt/states/ldap.py index 227182b828b..9b88c96918f 100644 --- a/salt/states/ldap.py +++ b/salt/states/ldap.py @@ -314,6 +314,7 @@ def managed(name, entries, connect_spec=None): o = old.get(dn, {}) n = new.get(dn, {}) + op = None try: # perform the operation if o: diff --git a/salt/states/netsnmp.py b/salt/states/netsnmp.py index be2c4ccec5d..f18dbd8b44f 100644 --- a/salt/states/netsnmp.py +++ b/salt/states/netsnmp.py @@ -110,7 +110,7 @@ def _clear_community_details(community_details): _mode = community_details.get["mode"] = community_details.get("mode").lower() - if _mode in _COMMUNITY_MODE_MAP.keys(): + if _mode in _COMMUNITY_MODE_MAP: community_details["mode"] = _COMMUNITY_MODE_MAP.get(_mode) if community_details["mode"] not in ["ro", "rw"]: @@ -191,7 +191,7 @@ def _create_diff_action(diff, diff_key, key, value): DRY to build diff parts (added, removed, updated). """ - if diff_key not in diff.keys(): + if diff_key not in diff: diff[diff_key] = {} diff[diff_key][key] = value diff --git a/salt/states/pip_state.py b/salt/states/pip_state.py index a262e16261e..747127ce50e 100644 --- a/salt/states/pip_state.py +++ b/salt/states/pip_state.py @@ -354,7 +354,10 @@ def _pep440_version_cmp(pkg1, pkg2, ignore_epoch=False): "The pkg_resources packages was not loaded. Please install setuptools." ) return None - normalize = lambda x: str(x).split("!", 1)[-1] if ignore_epoch else str(x) + + def normalize(x): + return str(x).split("!", 1)[-1] if ignore_epoch else str(x) + pkg1 = normalize(pkg1) pkg2 = normalize(pkg2) @@ -367,7 +370,7 @@ def _pep440_version_cmp(pkg1, pkg2, ignore_epoch=False): return 1 except Exception as exc: # pylint: disable=broad-except logger.exception( - f'Comparison of package versions "{pkg1}" and "{pkg2}" failed: {exc}' + 'Comparison of package versions "%s" and "%s" failed: %s', pkg1, pkg2, exc ) return None @@ -753,11 +756,13 @@ def installed( # prepro = lambda pkg: pkg if type(pkg) == str else \ # ' '.join((pkg.items()[0][0], pkg.items()[0][1].replace(',', ';'))) # pkgs = ','.join([prepro(pkg) for pkg in pkgs]) - prepro = lambda pkg: ( - pkg - if isinstance(pkg, str) - else " ".join((pkg.items()[0][0], pkg.items()[0][1])) - ) + def prepro(pkg): + return ( + pkg + if isinstance(pkg, str) + else " ".join((pkg.items()[0][0], pkg.items()[0][1])) + ) + pkgs = [prepro(pkg) for pkg in pkgs] ret = {"name": ";".join(pkgs), "result": None, "comment": "", "changes": {}} @@ -880,7 +885,8 @@ def installed( # If we fail, then just send False, and we'll try again in the next function call except Exception as exc: # pylint: disable=broad-except logger.exception( - f"Pre-caching of PIP packages during states.pip.installed failed by exception from pip.list: {exc}" + "Pre-caching of PIP packages during states.pip.installed failed by exception from pip.list: %s", + exc, ) pip_list = False diff --git a/salt/states/pkg.py b/salt/states/pkg.py index 1e7336749cd..da31436376b 100644 --- a/salt/states/pkg.py +++ b/salt/states/pkg.py @@ -4004,7 +4004,7 @@ def unheld(name, version=None, pkgs=None, all=False, **kwargs): (pkg_name, pkg_ver) = next(iter(pkg.items())) dpkgs.update({pkg_name: pkg_ver}) else: - dpkgs.update({pkg: None}) + dpkgs.update({pkg: None}) # pylint: disable=unhashable-member ret = {"name": name, "changes": {}, "result": True, "comment": ""} comments = [] diff --git a/salt/states/probes.py b/salt/states/probes.py index 23f34e85328..1c7e7525000 100644 --- a/salt/states/probes.py +++ b/salt/states/probes.py @@ -77,7 +77,7 @@ def _expand_probes(probes, defaults): expected_probes = {} for probe_name, probe_test in probes.items(): - if probe_name not in expected_probes.keys(): + if probe_name not in expected_probes: expected_probes[probe_name] = {} probe_defaults = probe_test.pop("defaults", {}) for test_name, test_details in probe_test.items(): @@ -94,7 +94,7 @@ def _expand_probes(probes, defaults): expected_test_details.update( test_details ) # update with the actual config of the test - if test_name not in expected_probes[probe_name].keys(): + if test_name not in expected_probes[probe_name]: expected_probes[probe_name][test_name] = expected_test_details return expected_probes @@ -162,12 +162,12 @@ def _compare_probes(configured_probes, expected_probes): # new tests for common probes for test_name in new_tests_keys_set: - if probe_name not in new_probes.keys(): + if probe_name not in new_probes: new_probes[probe_name] = {} new_probes[probe_name].update({test_name: probe_tests.pop(test_name)}) # old tests for common probes for test_name in remove_tests_keys_set: - if probe_name not in remove_probes.keys(): + if probe_name not in remove_probes: remove_probes[probe_name] = {} remove_probes[probe_name].update( {test_name: configured_probe_tests.pop(test_name)} @@ -177,7 +177,7 @@ def _compare_probes(configured_probes, expected_probes): configured_test_params = configured_probe_tests.get(test_name, {}) # if test params are different, probe goes to update probes dict! if test_params != configured_test_params: - if probe_name not in update_probes.keys(): + if probe_name not in update_probes: update_probes[probe_name] = {} update_probes[probe_name].update({test_name: test_params}) diff --git a/salt/states/saltmod.py b/salt/states/saltmod.py index c6a194ef1db..31c069843bd 100644 --- a/salt/states/saltmod.py +++ b/salt/states/saltmod.py @@ -784,7 +784,9 @@ def runner(name, **kwargs): try: kwargs["__pub_user"] = __user__ log.debug( - f"added __pub_user to kwargs using dunder user '{__user__}', kwargs '{kwargs}'" + "added __pub_user to kwargs using dunder user '%s', kwargs '%s'", + __user__, + kwargs, ) except NameError: log.warning("unable to find user for fire args event due to missing __user__") diff --git a/salt/states/win_iis.py b/salt/states/win_iis.py index da9a01a2b35..1f8c6a80d61 100644 --- a/salt/states/win_iis.py +++ b/salt/states/win_iis.py @@ -501,7 +501,7 @@ def container_setting(name, container, settings=None): # map identity type from numeric to string for comparing if ( setting == "processModel.identityType" - and settings[setting] in identityType_map2string.keys() + and settings[setting] in identityType_map2string ): settings[setting] = identityType_map2string[settings[setting]] diff --git a/salt/transport/base.py b/salt/transport/base.py index 178d4ac13d8..4a491d87ce5 100644 --- a/salt/transport/base.py +++ b/salt/transport/base.py @@ -403,7 +403,7 @@ class PublishClient(Transport): """ raise NotImplementedError - async def connect( # pylint: disable=arguments-differ + async def connect( # pylint: disable=arguments-differ,invalid-overridden-method self, port=None, connect_callback=None, disconnect_callback=None, timeout=None ): """ diff --git a/salt/transport/ipc.py b/salt/transport/ipc.py index 5421c60d1e5..0ac845954b8 100644 --- a/salt/transport/ipc.py +++ b/salt/transport/ipc.py @@ -177,13 +177,7 @@ class IPCServer: else: return _null - # msgpack deprecated `encoding` starting with version 0.5.2 - if salt.utils.msgpack.version >= (0, 5, 2): - # Under Py2 we still want raw to be set to True - msgpack_kwargs = {"raw": False} - else: - msgpack_kwargs = {"encoding": "utf-8"} - unpacker = salt.utils.msgpack.Unpacker(**msgpack_kwargs) + unpacker = salt.utils.msgpack.Unpacker(raw=False) while not stream.closed(): try: wire_bytes = yield stream.read_bytes(4096, partial=True) @@ -282,13 +276,7 @@ class IPCClient: self.socket_path = socket_path self._closing = False self.stream = None - # msgpack deprecated `encoding` starting with version 0.5.2 - if salt.utils.msgpack.version >= (0, 5, 2): - # Under Py2 we still want raw to be set to True - msgpack_kwargs = {"raw": False} - else: - msgpack_kwargs = {"encoding": "utf-8"} - self.unpacker = salt.utils.msgpack.Unpacker(**msgpack_kwargs) + self.unpacker = salt.utils.msgpack.Unpacker(raw=False) self._connecting_future = None def connected(self): diff --git a/salt/transport/tcp.py b/salt/transport/tcp.py index 42ab887aec9..d80072278bb 100644 --- a/salt/transport/tcp.py +++ b/salt/transport/tcp.py @@ -620,7 +620,7 @@ class SaltMessageServer(tornado.tcpserver.TCPServer): self.clients = [] self.message_handler = message_handler - async def handle_stream( # pylint: disable=arguments-differ + async def handle_stream( # pylint: disable=arguments-differ,invalid-overridden-method self, stream, address, @@ -1474,7 +1474,9 @@ class PublishServer(salt.transport.base.DaemonizedPublishServer): ) self.pub_sock.connect(timeout=timeout) - async def publish(self, payload, **kwargs): + async def publish( + self, payload, **kwargs + ): # pylint: disable=invalid-overridden-method """ Publish "load" to minions """ @@ -1744,7 +1746,7 @@ class RequestClient(salt.transport.base.RequestClient): await asyncio.sleep(self.backoff) return stream - async def connect(self): + async def connect(self): # pylint: disable=invalid-overridden-method if self._stream is None: self._connect_called = True self._stream = await self.getstream() diff --git a/salt/transport/zeromq.py b/salt/transport/zeromq.py index 43f335a2338..8bc4d0dff26 100644 --- a/salt/transport/zeromq.py +++ b/salt/transport/zeromq.py @@ -1037,7 +1037,9 @@ class PublishServer(salt.transport.base.DaemonizedPublishServer): self.daemon_context.destroy(1) self.daemon_context.term() - async def publish(self, payload, **kwargs): + async def publish( + self, payload, **kwargs + ): # pylint: disable=invalid-overridden-method """ Publish "load" to minions. This send the load to the publisher daemon process with does the actual sending to minions. @@ -1081,7 +1083,7 @@ class RequestClient(salt.transport.base.RequestClient): self.socket = None self.sending = asyncio.Lock() - async def connect(self): + async def connect(self): # pylint: disable=invalid-overridden-method if self.socket is None: self._connect_called = True self._closing = False diff --git a/salt/utils/ansible.py b/salt/utils/ansible.py index d75740e30f2..e0f35146999 100644 --- a/salt/utils/ansible.py +++ b/salt/utils/ansible.py @@ -12,7 +12,7 @@ __virtualname__ = "ansible" log = logging.getLogger(__name__) -def __virtual__(): # pylint: disable=expected-2-blank-lines-found-0 +def __virtual__(): if salt.utils.path.which("ansible-inventory"): return __virtualname__ return (False, "Install `ansible` to use inventory") diff --git a/salt/utils/args.py b/salt/utils/args.py index e34c208d6dd..551099ce7b4 100644 --- a/salt/utils/args.py +++ b/salt/utils/args.py @@ -345,7 +345,10 @@ def split_input(val, mapper=None): Take an input value and split it into a list, returning the resulting list """ if mapper is None: - mapper = lambda x: x + + def mapper(x): + return x + if isinstance(val, list): return list(map(mapper, val)) try: diff --git a/salt/utils/atomicfile.py b/salt/utils/atomicfile.py index d36733c83fb..5dfffbb83c2 100644 --- a/salt/utils/atomicfile.py +++ b/salt/utils/atomicfile.py @@ -15,8 +15,12 @@ import salt.utils.win_dacl CAN_RENAME_OPEN_FILE = False if os.name == "nt": # pragma: no cover - _rename = lambda src, dst: False # pylint: disable=C0103 - _rename_atomic = lambda src, dst: False # pylint: disable=C0103 + + def _rename(src, dst): + return False + + def _rename_atomic(src, dst): + return False try: import ctypes diff --git a/salt/utils/aws.py b/salt/utils/aws.py index 4c581a06c92..615aee19040 100644 --- a/salt/utils/aws.py +++ b/salt/utils/aws.py @@ -239,7 +239,14 @@ def assumed_creds(prov_dict, role_arn, location=None): requesturl="https://sts.amazonaws.com/", ) headers["Accept"] = "application/json" - result = requests.request("GET", requesturl, headers=headers, data="", verify=True) + result = requests.request( + "GET", + requesturl, + headers=headers, + data="", + verify=True, + timeout=AWS_METADATA_TIMEOUT, + ) if result.status_code >= 400: log.info("AssumeRole response: %s", result.content) @@ -506,7 +513,10 @@ def query( log.trace("AWS Request Parameters: %s", params_with_headers) try: result = requests.get( - requesturl, headers=headers, params=params_with_headers + requesturl, + headers=headers, + params=params_with_headers, + timeout=AWS_METADATA_TIMEOUT, ) log.debug("AWS Response Status Code: %s", result.status_code) log.trace("AWS Response Text: %s", result.text) diff --git a/salt/utils/cache.py b/salt/utils/cache.py index 65dd3a5f5eb..194efdca30f 100644 --- a/salt/utils/cache.py +++ b/salt/utils/cache.py @@ -99,7 +99,7 @@ class CacheDisk(CacheDict): return if time.time() - self._key_cache_time[key] > self._ttl: del self._key_cache_time[key] - self._dict.__delitem__(key) + del self._dict[key] def __contains__(self, key): self._enforce_ttl_key(key) @@ -365,7 +365,7 @@ def verify_cache_version(cache_path): file.seek(0) data = "\n".join(file.readlines()) if data != salt.version.__version__: - log.warning(f"Cache version mismatch clearing: {repr(cache_path)}") + log.warning("Cache version mismatch clearing: %s", repr(cache_path)) file.truncate(0) file.write(salt.version.__version__) for item in os.listdir(cache_path): diff --git a/salt/utils/cloud.py b/salt/utils/cloud.py index 0f3e27c2a24..ab389610938 100644 --- a/salt/utils/cloud.py +++ b/salt/utils/cloud.py @@ -2119,9 +2119,7 @@ def _exec_ssh_cmd(cmd, error_msg=None, allow_failure=False, **kwargs): return proc.exitstatus except salt.utils.vt.TerminalException as err: trace = traceback.format_exc() - log.error( - error_msg.format(cmd, err, trace) - ) # pylint: disable=str-format-in-logging + log.error(error_msg.format(cmd, err, trace)) finally: proc.close(terminate=True, kill=True) # Signal an error @@ -2968,7 +2966,7 @@ def update_bootstrap(config, url=None): "Python requests library to be installed" ) } - req = requests.get(url) + req = requests.get(url, timeout=120) if req.status_code != 200: return { "error": ( diff --git a/salt/utils/compat.py b/salt/utils/compat.py index 0579a7f5e62..d9313e1b408 100644 --- a/salt/utils/compat.py +++ b/salt/utils/compat.py @@ -38,12 +38,10 @@ def deepcopy_bound(name): """ def _deepcopy_method(x, memo): - # pylint: disable=incompatible-py3-code return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class) - # pylint: enable=incompatible-py3-code + pre_dispatch = copy._deepcopy_dispatch try: - pre_dispatch = copy._deepcopy_dispatch copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method ret = copy.deepcopy(name) finally: diff --git a/salt/utils/configparser.py b/salt/utils/configparser.py index f4d72c68343..b636d5e320e 100644 --- a/salt/utils/configparser.py +++ b/salt/utils/configparser.py @@ -3,18 +3,12 @@ Custom configparser classes """ import re +from collections import OrderedDict from configparser import * # pylint: disable=no-name-in-module,wildcard-import,unused-wildcard-import import salt.utils.stringutils -try: - from collections import OrderedDict as _default_dict -except ImportError: - # fallback for setup.py which hasn't yet built _collections - _default_dict = dict - -# pylint: disable=string-substitution-usage-error class GitConfigParser(RawConfigParser): """ Custom ConfigParser which reads and writes git config files. @@ -47,7 +41,7 @@ class GitConfigParser(RawConfigParser): def __init__( self, defaults=None, - dict_type=_default_dict, + dict_type=OrderedDict, allow_no_value=True, ): """ diff --git a/salt/utils/data.py b/salt/utils/data.py index 5b7cc8fbea6..6bf8b901135 100644 --- a/salt/utils/data.py +++ b/salt/utils/data.py @@ -1048,9 +1048,14 @@ def repack_dictlist(data, strict=False, recurse=False, key_cb=None, val_cb=None) return {} if key_cb is None: - key_cb = lambda x: x + + def key_cb(x): + return x + if val_cb is None: - val_cb = lambda x, y: y + + def val_cb(x, y): + return y valid_non_dict = ((str,), (int,), float) if isinstance(data, list): diff --git a/salt/utils/dns.py b/salt/utils/dns.py index 2a7cd420cf7..271fd79553e 100644 --- a/salt/utils/dns.py +++ b/salt/utils/dns.py @@ -583,7 +583,6 @@ def lookup( rdtype = rdtype.upper() - # pylint: disable=bad-whitespace,multiple-spaces-before-keyword query_methods = ( ("gai", _lookup_gai, not any((rdtype not in ("A", "AAAA"), servers, secure))), ("dnspython", _lookup_dnspython, HAS_DNSPYTHON), @@ -592,7 +591,6 @@ def lookup( ("host", _lookup_host, HAS_HOST and not secure), ("nslookup", _lookup_nslookup, HAS_NSLOOKUP and not secure), ) - # pylint: enable=bad-whitespace,multiple-spaces-before-keyword try: if method == "auto": diff --git a/salt/utils/dockermod/__init__.py b/salt/utils/dockermod/__init__.py index 73f1be23a15..d0f504e60dc 100644 --- a/salt/utils/dockermod/__init__.py +++ b/salt/utils/dockermod/__init__.py @@ -24,11 +24,11 @@ except ImportError: # functions so that we can get argspecs for the container config, host config, # and networking config (see the get_client_args() function). try: - import docker.types + import docker.types # pylint: disable=no-name-in-module except ImportError: pass try: - import docker.utils + import docker.utils # pylint: disable=no-name-in-module except ImportError: pass @@ -240,7 +240,7 @@ def translate_input( pass except Exception as exc: # pylint: disable=broad-except - error_message = exc.__str__() + error_message = str(exc) log.error("Error translating input: '%s'", error_message, exc_info=True) else: error_message = None diff --git a/salt/utils/dockermod/translate/container.py b/salt/utils/dockermod/translate/container.py index a59fd9c7e82..6d8e012f9ad 100644 --- a/salt/utils/dockermod/translate/container.py +++ b/salt/utils/dockermod/translate/container.py @@ -378,9 +378,7 @@ def port_bindings(val, **kwargs): try: start, end = helpers.get_port_range(container_port) except ValueError as exc: - # Using __str__() to avoid deprecation warning for using - # the message attribute of the ValueError. - raise SaltInvocationError(exc.__str__()) + raise SaltInvocationError(str(exc)) bind_vals = [ (_format_port(port_num, proto), None) for port_num in range(start, end + 1) @@ -403,9 +401,7 @@ def port_bindings(val, **kwargs): cport_start, cport_end = helpers.get_port_range(container_port) hport_start, hport_end = helpers.get_port_range(bind_parts[0]) except ValueError as exc: - # Using __str__() to avoid deprecation warning for - # using the message attribute of the ValueError. - raise SaltInvocationError(exc.__str__()) + raise SaltInvocationError(str(exc)) if (hport_end - hport_start) != (cport_end - cport_start): # Port range is mismatched raise SaltInvocationError( @@ -427,9 +423,7 @@ def port_bindings(val, **kwargs): try: cport_start, cport_end = helpers.get_port_range(container_port) except ValueError as exc: - # Using __str__() to avoid deprecation warning for - # using the message attribute of the ValueError. - raise SaltInvocationError(exc.__str__()) + raise SaltInvocationError(str(exc)) cport_list = list(range(cport_start, cport_end + 1)) if host_port == "": hport_list = [None] * len(cport_list) @@ -437,9 +431,7 @@ def port_bindings(val, **kwargs): try: hport_start, hport_end = helpers.get_port_range(host_port) except ValueError as exc: - # Using __str__() to avoid deprecation warning for - # using the message attribute of the ValueError. - raise SaltInvocationError(exc.__str__()) + raise SaltInvocationError(str(exc)) hport_list = list(range(hport_start, hport_end + 1)) if (hport_end - hport_start) != (cport_end - cport_start): @@ -524,9 +516,7 @@ def ports(val, **kwargs): # pylint: disable=unused-argument try: range_start, range_end = helpers.get_port_range(item) except ValueError as exc: - # Using __str__() to avoid deprecation warning for using - # the "message" attribute of the ValueError. - raise SaltInvocationError(exc.__str__()) + raise SaltInvocationError(str(exc)) new_ports.update( [helpers.get_port_def(x, proto) for x in range(range_start, range_end + 1)] ) diff --git a/salt/utils/dockermod/translate/helpers.py b/salt/utils/dockermod/translate/helpers.py index deb0e50ec5f..948beb41e94 100644 --- a/salt/utils/dockermod/translate/helpers.py +++ b/salt/utils/dockermod/translate/helpers.py @@ -72,7 +72,7 @@ def get_port_range(port_def): if range_start > range_end: raise ValueError("start > end") except (TypeError, ValueError) as exc: - if exc.__str__() == "start > end": + if str(exc) == "start > end": msg = ( "Start of port range ({}) cannot be greater than end of " "port range ({})".format(range_start, range_end) diff --git a/salt/utils/files.py b/salt/utils/files.py index 8f6cf980d66..e5494911c28 100644 --- a/salt/utils/files.py +++ b/salt/utils/files.py @@ -317,8 +317,8 @@ def set_umask(mask): # Don't attempt on Windows, or if no mask was passed yield else: + orig_mask = os.umask(mask) # pylint: disable=blacklisted-function try: - orig_mask = os.umask(mask) # pylint: disable=blacklisted-function yield finally: os.umask(orig_mask) # pylint: disable=blacklisted-function @@ -385,7 +385,9 @@ def fopen(*args, **kwargs): ) kwargs["buffering"] = io.DEFAULT_BUFFER_SIZE - f_handle = open(*args, **kwargs) # pylint: disable=resource-leakage + f_handle = open( # pylint: disable=resource-leakage,unspecified-encoding + *args, **kwargs + ) if is_fcntl_available(): # modify the file descriptor on systems with fcntl @@ -644,7 +646,10 @@ def is_text(fp_, blocksize=512): If more than 30% of the chars in the block are non-text, or there are NUL ('\x00') bytes in the block, assume this is a binary file. """ - int2byte = lambda x: bytes((x,)) + + def int2byte(x): + return bytes((x,)) + text_characters = b"".join(int2byte(i) for i in range(32, 127)) + b"\n\r\t\f\b" try: block = fp_.read(blocksize) diff --git a/salt/utils/fsutils.py b/salt/utils/fsutils.py index 6c93534085c..c1ea06f1851 100644 --- a/salt/utils/fsutils.py +++ b/salt/utils/fsutils.py @@ -58,7 +58,10 @@ def _blkid_output(out, fs_type=None): """ Parse blkid output. """ - flt = lambda data: [el for el in data if el.strip()] + + def flt(data): + return [el for el in data if el.strip()] + data = {} for dev_meta in flt(out.split("\n\n")): dev = {} @@ -85,7 +88,10 @@ def _blkid(fs_type=None): :param fs_type: Filter only devices that are formatted by that file system. """ - flt = lambda data: [el for el in data if el.strip()] + + def flt(data): + return [el for el in data if el.strip()] + data = dict() for dev_meta in flt( os.popen("blkid -o full").read().split(os.linesep) diff --git a/salt/utils/functools.py b/salt/utils/functools.py index 74e9012124c..224d096957c 100644 --- a/salt/utils/functools.py +++ b/salt/utils/functools.py @@ -120,9 +120,7 @@ def call_function(salt_function, *args, **kwargs): # function_kwargs is initialized to a dictionary of keyword arguments the function to be run accepts function_kwargs = dict( zip( - argspec.args[ - -len(argspec.defaults or []) : - ], # pylint: disable=incompatible-py3-code + argspec.args[-len(argspec.defaults or []) :], argspec.defaults or [], ) ) diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py index 056e4782636..a047c60d33d 100644 --- a/salt/utils/gitfs.py +++ b/salt/utils/gitfs.py @@ -119,7 +119,7 @@ try: if PYGIT2_VERSION <= Version("0.26.3"): try: import pygit2.ffi - import pygit2.remote + import pygit2.remote # pylint: disable=no-name-in-module except ImportError: # If we couldn't import these, then we're using an old enough # version where ffi isn't in use and this workaround would be @@ -245,12 +245,16 @@ class GitProvider: ): self.opts = opts self.role = role + + def _val_cb(x, y): + return str(y) + self.global_saltenv = salt.utils.data.repack_dictlist( self.opts.get(f"{self.role}_saltenv", []), strict=True, recurse=True, key_cb=str, - val_cb=lambda x, y: str(y), + val_cb=_val_cb, ) self.conf = copy.deepcopy(per_remote_defaults) # Remove the 'salt://' from the beginning of any globally-defined @@ -474,7 +478,9 @@ class GitProvider: try: self._cache_basename = self.get_checkout_target() except AttributeError: - log.critical(f"__env__ cant generate basename: {self.role} {self.id}") + log.critical( + "__env__ cant generate basename: %s %s", self.role, self.id + ) failhard(self.role) self._cache_full_basename = salt.utils.path.join( self._cache_basehash, self._cache_basename @@ -575,9 +581,9 @@ class GitProvider: """ def _getconf(self, tgt_env="base"): - strip_sep = lambda x: ( - x.rstrip(os.sep) if name in ("root", "mountpoint") else x - ) + def strip_sep(x): + return x.rstrip(os.sep) if name in ("root", "mountpoint") else x + if self.role != "gitfs": return strip_sep(getattr(self, "_" + name)) # Get saltenv-specific configuration @@ -1204,12 +1210,14 @@ class GitProvider: def fetch_request_check(self): fetch_request = salt.utils.path.join(self._salt_working_dir, "fetch_request") if os.path.isfile(fetch_request): - log.debug(f"Fetch request: {self._salt_working_dir}") + log.debug("Fetch request: %s", self._salt_working_dir) try: os.remove(fetch_request) except OSError as exc: log.error( - f"Failed to remove Fetch request: {self._salt_working_dir} {exc}", + "Failed to remove Fetch request: %s %s", + self._salt_working_dir, + exc, exc_info=True, ) self.fetch() @@ -1427,12 +1435,20 @@ class GitPython(GitProvider): tree = tree / self.root(tgt_env) except KeyError: return ret - relpath = lambda path: os.path.relpath(path, self.root(tgt_env)) + + def relpath(path): + return os.path.relpath(path, self.root(tgt_env)) + else: - relpath = lambda path: path - add_mountpoint = lambda path: salt.utils.path.join( - self.mountpoint(tgt_env), path, use_posixpath=True - ) + + def relpath(path): + return path + + def add_mountpoint(path): + return salt.utils.path.join( + self.mountpoint(tgt_env), path, use_posixpath=True + ) + for blob in tree.traverse(): if isinstance(blob, git.Tree): ret.add(add_mountpoint(relpath(blob.path))) @@ -1499,12 +1515,20 @@ class GitPython(GitProvider): tree = tree / self.root(tgt_env) except KeyError: return files, symlinks - relpath = lambda path: os.path.relpath(path, self.root(tgt_env)) + + def relpath(path): + return os.path.relpath(path, self.root(tgt_env)) + else: - relpath = lambda path: path - add_mountpoint = lambda path: salt.utils.path.join( - self.mountpoint(tgt_env), path, use_posixpath=True - ) + + def relpath(path): + return path + + def add_mountpoint(path): + return salt.utils.path.join( + self.mountpoint(tgt_env), path, use_posixpath=True + ) + for file_blob in tree.traverse(): if not isinstance(file_blob, git.Blob): continue @@ -1946,15 +1970,24 @@ class Pygit2(GitProvider): return ret if not isinstance(tree, pygit2.Tree): return ret - relpath = lambda path: os.path.relpath(path, self.root(tgt_env)) + + def relpath(path): + return os.path.relpath(path, self.root(tgt_env)) + else: - relpath = lambda path: path + + def relpath(path): + return path + blobs = [] if tree: _traverse(tree, blobs, self.root(tgt_env)) - add_mountpoint = lambda path: salt.utils.path.join( - self.mountpoint(tgt_env), path, use_posixpath=True - ) + + def add_mountpoint(path): + return salt.utils.path.join( + self.mountpoint(tgt_env), path, use_posixpath=True + ) + for blob in blobs: ret.add(add_mountpoint(relpath(blob))) if self.mountpoint(tgt_env): @@ -2087,15 +2120,24 @@ class Pygit2(GitProvider): return files, symlinks if not isinstance(tree, pygit2.Tree): return files, symlinks - relpath = lambda path: os.path.relpath(path, self.root(tgt_env)) + + def relpath(path): + return os.path.relpath(path, self.root(tgt_env)) + else: - relpath = lambda path: path + + def relpath(path): + return path + blobs = {} if tree: _traverse(tree, blobs, self.root(tgt_env)) - add_mountpoint = lambda path: salt.utils.path.join( - self.mountpoint(tgt_env), path, use_posixpath=True - ) + + def add_mountpoint(path): + return salt.utils.path.join( + self.mountpoint(tgt_env), path, use_posixpath=True + ) + for repo_path in blobs.get("files", []): files.add(add_mountpoint(relpath(repo_path))) for repo_path, link_tgt in blobs.get("symlinks", {}).items(): @@ -2180,9 +2222,12 @@ class Pygit2(GitProvider): if PYGIT2_VERSION >= Version("0.23.2"): self.remotecallbacks = pygit2.RemoteCallbacks(credentials=self.credentials) if not self.ssl_verify: - # Override the certificate_check function with a lambda that + # Override the certificate_check function with another that # just returns True, thus skipping the cert check. - self.remotecallbacks.certificate_check = lambda *args, **kwargs: True + def _certificate_check(*args, **kwargs): + return True + + self.remotecallbacks.certificate_check = _certificate_check else: self.remotecallbacks = None if not self.ssl_verify: @@ -2660,11 +2705,13 @@ class GitBase: pass except OSError as exc: # pylint: disable=broad-except log.error( - f"Failed to make fetch request: {fetch_path} {exc}", + "Failed to make fetch request: %s %s", + fetch_path, + exc, exc_info=True, ) else: - log.error(f"Failed to make fetch request: {fetch_path}") + log.error("Failed to make fetch request: %s", fetch_path) if repo.fetch(): # We can't just use the return value from repo.fetch() # because the data could still have changed if old @@ -3434,7 +3481,7 @@ class GitPillar(GitBase): "Failed to remove existing git_pillar " "mountpoint link %s: %s", lcachelink, - exc.__str__(), + exc, ) wipe_linkdir = False create_link = True @@ -3454,7 +3501,7 @@ class GitPillar(GitBase): log.error( "Failed to os.makedirs() linkdir parent %s: %s", ldirname, - exc.__str__(), + exc, ) return False @@ -3472,7 +3519,7 @@ class GitPillar(GitBase): "Failed to create symlink to %s at path %s: %s", lcachedest, lcachelink, - exc.__str__(), + exc, ) return False except GitLockError: diff --git a/salt/utils/iam.py b/salt/utils/iam.py index dea1e950145..45017df57ef 100644 --- a/salt/utils/iam.py +++ b/salt/utils/iam.py @@ -24,6 +24,7 @@ def _retry_get_url(url, num_retries=10, timeout=5): Based heavily on boto.utils.retry_url """ for i in range(0, num_retries): + exc = None try: result = requests.get(url, timeout=timeout, proxies={"http": ""}) if hasattr(result, "text"): diff --git a/salt/utils/jinja.py b/salt/utils/jinja.py index 898c8d3fc0d..f802156ddb8 100644 --- a/salt/utils/jinja.py +++ b/salt/utils/jinja.py @@ -239,9 +239,7 @@ class PrintableDict(OrderedDict): for key, value in self.items(): if isinstance(value, str): # keeps quotes around strings - # pylint: disable=repr-flag-used-in-string output.append(f"{key!r}: {value!r}") - # pylint: enable=repr-flag-used-in-string else: # let default output output.append(f"{key!r}: {value!s}") @@ -252,9 +250,7 @@ class PrintableDict(OrderedDict): for key, value in self.items(): # Raw string formatter required here because this is a repr # function. - # pylint: disable=repr-flag-used-in-string output.append(f"{key!r}: {value!r}") - # pylint: enable=repr-flag-used-in-string return "{" + ", ".join(output) + "}" diff --git a/salt/utils/msgpack.py b/salt/utils/msgpack.py index 034ce5dd366..6dde58938ff 100644 --- a/salt/utils/msgpack.py +++ b/salt/utils/msgpack.py @@ -12,13 +12,10 @@ try: # There is a serialization issue on ARM and potentially other platforms for some msgpack bindings, check for it if ( - msgpack.version >= (0, 4, 0) - and msgpack.loads(msgpack.dumps([1, 2, 3], use_bin_type=False), use_list=True) + msgpack.loads(msgpack.dumps([1, 2, 3], use_bin_type=False), use_list=True) is None ): raise ImportError - elif msgpack.loads(msgpack.dumps([1, 2, 3]), use_list=True) is None: - raise ImportError HAS_MSGPACK = True except ImportError: try: @@ -60,9 +57,7 @@ def _sanitize_msgpack_kwargs(kwargs): https://github.com/msgpack/msgpack-python/blob/master/ChangeLog.rst """ assert isinstance(kwargs, dict) - if version < (0, 6, 0) and kwargs.pop("strict_map_key", None) is not None: - log.info("removing unsupported `strict_map_key` argument from msgpack call") - if version >= (1, 0, 0) and kwargs.pop("encoding", None) is not None: + if kwargs.pop("encoding", None) is not None: log.debug("removing unsupported `encoding` argument from msgpack call") return kwargs @@ -75,32 +70,20 @@ def _sanitize_msgpack_unpack_kwargs(kwargs): https://github.com/msgpack/msgpack-python/blob/master/ChangeLog.rst """ assert isinstance(kwargs, dict) - if version >= (1, 0, 0): - kwargs.setdefault("raw", True) - kwargs.setdefault("strict_map_key", False) + kwargs.setdefault("raw", True) + kwargs.setdefault("strict_map_key", False) return _sanitize_msgpack_kwargs(kwargs) -def _add_msgpack_unpack_kwargs(kwargs): - """ - Add any msgpack unpack kwargs here. - - max_buffer_size: will make sure the buffer is set to a minimum - of 100MiB in versions >=6 and <1.0 - """ - assert isinstance(kwargs, dict) - if version >= (0, 6, 0) and version < (1, 0, 0): - kwargs["max_buffer_size"] = 100 * 1024 * 1024 - return _sanitize_msgpack_unpack_kwargs(kwargs) - - class Unpacker(msgpack.Unpacker): """ Wraps the msgpack.Unpacker and removes non-relevant arguments """ def __init__(self, *args, **kwargs): - msgpack.Unpacker.__init__(self, *args, **_add_msgpack_unpack_kwargs(kwargs)) + msgpack.Unpacker.__init__( + self, *args, **_sanitize_msgpack_unpack_kwargs(kwargs) + ) def pack(o, stream, **kwargs): diff --git a/salt/utils/nacl.py b/salt/utils/nacl.py index 746fd8aeaa4..cac3455d1a6 100644 --- a/salt/utils/nacl.py +++ b/salt/utils/nacl.py @@ -15,9 +15,9 @@ import salt.utils.win_functions REQ_ERROR = None try: - import nacl.public - import nacl.secret -except (ImportError, OSError) as e: + import nacl.public # pylint: disable=no-name-in-module + import nacl.secret # pylint: disable=no-name-in-module +except ImportError: REQ_ERROR = ( "PyNaCl import error, perhaps missing python PyNaCl package or should update." ) diff --git a/salt/utils/napalm.py b/salt/utils/napalm.py index 6d3ef580eed..9fc15e45fdb 100644 --- a/salt/utils/napalm.py +++ b/salt/utils/napalm.py @@ -43,8 +43,11 @@ try: # try importing ConnectionClosedException # from napalm-base # this exception has been introduced only in version 0.24.0 + # pylint: disable=unused-import,no-name-in-module from napalm.base.exceptions import ConnectionClosedException + # pylint: enable=unused-import,no-name-in-module + HAS_CONN_CLOSED_EXC_CLASS = True except ImportError: HAS_CONN_CLOSED_EXC_CLASS = False @@ -92,10 +95,8 @@ def virtual(opts, virtualname, filename): else: return ( False, - '"{vname}"" {filename} cannot be loaded: ' - "NAPALM is not installed: ``pip install napalm``".format( - vname=virtualname, filename=f"({filename})" - ), + f'"{virtualname}" ({filename}) cannot be loaded: ' + "NAPALM is not installed: ``pip install napalm``", ) diff --git a/salt/utils/nb_popen.py b/salt/utils/nb_popen.py index e878c730396..3f6afd4b85e 100644 --- a/salt/utils/nb_popen.py +++ b/salt/utils/nb_popen.py @@ -24,14 +24,12 @@ import time mswindows = sys.platform == "win32" -try: +if mswindows: import msvcrt import pywintypes from win32file import ReadFile, WriteFile from win32pipe import PeekNamedPipe -except ImportError: - import fcntl log = logging.getLogger(__name__) @@ -180,6 +178,8 @@ class NonBlockingPopen(subprocess.Popen): if conn is None: return None + import fcntl + flags = fcntl.fcntl(conn, fcntl.F_GETFL) if not conn.closed: fcntl.fcntl(conn, fcntl.F_SETFL, flags | os.O_NONBLOCK) diff --git a/salt/utils/network.py b/salt/utils/network.py index ed274a34eea..b415f572750 100644 --- a/salt/utils/network.py +++ b/salt/utils/network.py @@ -1718,9 +1718,7 @@ def _netlink_tool_remote_on(port, which_end): valid = False tcp_end = "dst" if which_end == "remote_port" else "src" try: - data = subprocess.check_output( - ["ss", "-ant", tcp_end, f":{port}"] - ) # pylint: disable=minimum-python-version + data = subprocess.check_output(["ss", "-ant", tcp_end, f":{port}"]) except subprocess.CalledProcessError: log.error("Failed ss") raise @@ -1766,9 +1764,7 @@ def _sunos_remotes_on(port, which_end): # pragma: no cover """ remotes = set() try: - data = subprocess.check_output( - ["netstat", "-f", "inet", "-n"] - ) # pylint: disable=minimum-python-version + data = subprocess.check_output(["netstat", "-f", "inet", "-n"]) except subprocess.CalledProcessError: log.error("Failed netstat") raise @@ -1814,7 +1810,7 @@ def _freebsd_remotes_on(port, which_end): # pragma: no cover try: cmd = salt.utils.args.shlex_split(f"sockstat -4 -c -p {port}") - data = subprocess.check_output(cmd) # pylint: disable=minimum-python-version + data = subprocess.check_output(cmd) except subprocess.CalledProcessError as ex: log.error('Failed "sockstat" with returncode = %s', ex.returncode) raise @@ -1876,7 +1872,7 @@ def _netbsd_remotes_on(port, which_end): # pragma: no cover try: cmd = salt.utils.args.shlex_split(f"sockstat -4 -c -n -p {port}") - data = subprocess.check_output(cmd) # pylint: disable=minimum-python-version + data = subprocess.check_output(cmd) except subprocess.CalledProcessError as ex: log.error('Failed "sockstat" with returncode = %s', ex.returncode) raise @@ -1928,9 +1924,7 @@ def _openbsd_remotes_on(port, which_end): # pragma: no cover """ remotes = set() try: - data = subprocess.check_output( - ["netstat", "-nf", "inet"] - ) # pylint: disable=minimum-python-version + data = subprocess.check_output(["netstat", "-nf", "inet"]) except subprocess.CalledProcessError as exc: log.error('Failed "netstat" with returncode = %s', exc.returncode) raise @@ -1969,9 +1963,7 @@ def _windows_remotes_on(port, which_end): """ remotes = set() try: - data = subprocess.check_output( - ["netstat", "-n"] - ) # pylint: disable=minimum-python-version + data = subprocess.check_output(["netstat", "-n"]) except subprocess.CalledProcessError: log.error("Failed netstat") raise @@ -2020,7 +2012,7 @@ def _linux_remotes_on(port, which_end): f"-iTCP:{port:d}", "-n", "-P", - ] # pylint: disable=minimum-python-version + ] ) except subprocess.CalledProcessError as ex: if ex.returncode == 1: @@ -2085,9 +2077,7 @@ def _aix_remotes_on(port, which_end): # pragma: no cover """ remotes = set() try: - data = subprocess.check_output( - ["netstat", "-f", "inet", "-n"] - ) # pylint: disable=minimum-python-version + data = subprocess.check_output(["netstat", "-f", "inet", "-n"]) except subprocess.CalledProcessError: log.error("Failed netstat") raise @@ -2325,9 +2315,8 @@ def filter_by_networks(values, networks): {{ grains['ipv4'] | filter_by_networks(networks) }} """ - _filter = lambda ips, networks: [ - ip for ip in ips for net in networks if ipaddress.ip_address(ip) in net - ] + def _filter(ips, networks): + return [ip for ip in ips for net in networks if ipaddress.ip_address(ip) in net] if networks is not None: networks = [ipaddress.ip_network(network) for network in networks] diff --git a/salt/utils/odict.py b/salt/utils/odict.py index b31bb020121..2834f1d9246 100644 --- a/salt/utils/odict.py +++ b/salt/utils/odict.py @@ -5,319 +5,17 @@ salt.utils.odict ~~~~~~~~~~~~~~~~ - This is a compatibility/"importability" layer for an ordered dictionary. - Tries to import from the standard library if python >= 2.7, then from the - ``ordereddict`` package available from PyPi, and, as a last resort, - provides an ``OrderedDict`` implementation based on:: - - http://code.activestate.com/recipes/576669/ - - It also implements a DefaultOrderedDict Class that serves as a + Implements a DefaultOrderedDict Class that serves as a combination of ``OrderedDict`` and ``defaultdict`` It's source was submitted here:: http://stackoverflow.com/questions/6190331/ """ -# pragma: no cover # essentially using Python's OrderDict - - +import copy +from collections import OrderedDict from collections.abc import Callable -import salt.utils.versions - -try: - # pylint: disable=E0611,minimum-python-version - import collections - - class OrderedDict(collections.OrderedDict): - __hash__ = None - -except (ImportError, AttributeError): - try: - import ordereddict - - class OrderedDict(ordereddict.OrderedDict): # pylint: disable=W0232 - __hash_ = None - - except ImportError: - # {{{ http://code.activestate.com/recipes/576693/ (r9) - # Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy. - # Passes Python2.7's test suite and incorporates all the latest updates. - - try: - from _thread import get_ident as _get_ident - except ImportError: - from _dummy_thread import get_ident as _get_ident - - # try: - # from _abcoll import KeysView, ValuesView, ItemsView - # except ImportError: - # pass - - class OrderedDict(dict): - "Dictionary that remembers insertion order" - # An inherited dict maps keys to values. - # The inherited dict provides __getitem__, __len__, __contains__, and get. - # The remaining methods are order-aware. - # Big-O running times for all methods are the same as for regular dictionaries. - - # The internal self.__map dictionary maps keys to links in a doubly linked list. - # The circular doubly linked list starts and ends with a sentinel element. - # The sentinel element never gets deleted (this simplifies the algorithm). - # Each link is stored as a list of length three: [PREV, NEXT, KEY]. - __hash_ = None - - def __init__(self, *args, **kwds): # pylint: disable=E1003 - """Initialize an ordered dictionary. Signature is the same as for - regular dictionaries, but keyword arguments are not recommended - because their insertion order is arbitrary. - - """ - salt.utils.versions.warn_until( - 3009, - "The Salt backport `OrderedDict` class introduced for Python 2 " - "has been deprecated, and is set to be removed in {version}. " - "Please import `OrderedDict` from `collections`.", - category=DeprecationWarning, - ) - - super().__init__() - if len(args) > 1: - raise TypeError(f"expected at most 1 arguments, got {len(args)}") - try: - self.__root - except AttributeError: - self.__root = root = [] # sentinel node - root[:] = [root, root, None] - self.__map = {} - self.__update(*args, **kwds) - - def __setitem__(self, key, value, dict_setitem=dict.__setitem__): - "od.__setitem__(i, y) <==> od[i]=y" - # Setting a new item creates a new link which goes at the end of the linked - # list, and the inherited dictionary is updated with the new key/value pair. - if key not in self: - root = self.__root - last = root[0] - last[1] = root[0] = self.__map[key] = [last, root, key] - dict_setitem(self, key, value) - - def __delitem__(self, key, dict_delitem=dict.__delitem__): - "od.__delitem__(y) <==> del od[y]" - # Deleting an existing item uses self.__map to find the link which is - # then removed by updating the links in the predecessor and successor nodes. - dict_delitem(self, key) - link_prev, link_next, key = self.__map.pop(key) - link_prev[1] = link_next - link_next[0] = link_prev - - def __iter__(self): - "od.__iter__() <==> iter(od)" - root = self.__root - curr = root[1] - while curr is not root: - yield curr[2] - curr = curr[1] - - def __reversed__(self): - "od.__reversed__() <==> reversed(od)" - root = self.__root - curr = root[0] - while curr is not root: - yield curr[2] - curr = curr[0] - - def clear(self): - "od.clear() -> None. Remove all items from od." - try: - for node in self.__map.values(): - del node[:] - root = self.__root - root[:] = [root, root, None] - self.__map.clear() - except AttributeError: - pass - dict.clear(self) - - def popitem(self, last=True): - """od.popitem() -> (k, v), return and remove a (key, value) pair. - Pairs are returned in LIFO order if last is true or FIFO order if false. - - """ - if not self: - raise KeyError("dictionary is empty") - root = self.__root - if last: - link = root[0] - link_prev = link[0] - link_prev[1] = root - root[0] = link_prev - else: - link = root[1] - link_next = link[1] - root[1] = link_next - link_next[0] = root - key = link[2] - del self.__map[key] - value = dict.pop(self, key) - return key, value - - # -- the following methods do not depend on the internal structure -- - - def keys(self): - "od.keys() -> list of keys in od" - return list(self) - - def values(self): - "od.values() -> list of values in od" - return [self[key] for key in self] - - def items(self): - "od.items() -> list of (key, value) pairs in od" - return [(key, self[key]) for key in self] - - def iterkeys(self): - "od.iterkeys() -> an iterator over the keys in od" - return iter(self) - - def itervalues(self): - "od.itervalues -> an iterator over the values in od" - for k in self: - yield self[k] - - def iteritems(self): - "od.iteritems -> an iterator over the (key, value) items in od" - for k in self: - yield (k, self[k]) - - def update(*args, **kwds): # pylint: disable=E0211 - """od.update(E, **F) -> None. Update od from dict/iterable E and F. - - If E is a dict instance, does: for k in E: od[k] = E[k] - If E has a .keys() method, does: for k in E.keys(): od[k] = E[k] - Or if E is an iterable of items, does: for k, v in E: od[k] = v - In either case, this is followed by: for k, v in F.items(): od[k] = v - - """ - if len(args) > 2: - raise TypeError( - "update() takes at most 2 positional " - "arguments ({} given)".format(len(args)) - ) - elif not args: - raise TypeError("update() takes at least 1 argument (0 given)") - self = args[0] - # Make progressively weaker assumptions about "other" - other = () - if len(args) == 2: - other = args[1] - if isinstance(other, dict): - for key in other: - self[key] = other[key] - elif hasattr(other, "keys"): - for key in other: - self[key] = other[key] - else: - for key, value in other: - self[key] = value - for key, value in kwds.items(): - self[key] = value - - __update = ( - update # let subclasses override update without breaking __init__ - ) - - __marker = object() - - def pop(self, key, default=__marker): - """od.pop(k[,d]) -> v, remove specified key and return the corresponding value. - If key is not found, d is returned if given, otherwise KeyError is raised. - - """ - if key in self: - result = self[key] - del self[key] - return result - if default is self.__marker: - raise KeyError(key) - return default - - def setdefault(self, key, default=None): - "od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od" - if key in self: - return self[key] - self[key] = default - return default - - def __repr__(self, _repr_running={}): # pylint: disable=W0102 - "od.__repr__() <==> repr(od)" - call_key = id(self), _get_ident() - if call_key in _repr_running: - return "..." - _repr_running[call_key] = 1 - try: - if not self: - return f"{self.__class__.__name__}()" - return "{}('{}')".format( - self.__class__.__name__, list(self.items()) - ) - finally: - del _repr_running[call_key] - - def __reduce__(self): - "Return state information for pickling" - items = [[k, self[k]] for k in self] - inst_dict = vars(self).copy() - for k in vars(OrderedDict()): - inst_dict.pop(k, None) - if inst_dict: - return (self.__class__, (items,), inst_dict) - return self.__class__, (items,) - - def copy(self): - "od.copy() -> a shallow copy of od" - return self.__class__(self) - - @classmethod - def fromkeys(cls, iterable, value=None): - """OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S - and values equal to v (which defaults to None). - - """ - d = cls() - for key in iterable: - d[key] = value - return d - - def __eq__(self, other): - """od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive - while comparison to a regular mapping is order-insensitive. - - """ - if isinstance(other, OrderedDict): - return len(self) == len(other) and self.items() == other.items() - return dict.__eq__(self, other) - - def __ne__(self, other): - return not self == other - - -# # -- the following methods are only used in Python 2.7 -- -# -# def viewkeys(self): -# "od.viewkeys() -> a set-like object providing a view on od's keys" -# return KeysView(self) -# -# def viewvalues(self): -# "od.viewvalues() -> an object providing a view on od's values" -# return ValuesView(self) -# -# def viewitems(self): -# "od.viewitems() -> a set-like object providing a view on od's items" -# return ItemsView(self) -# ## end of http://code.activestate.com/recipes/576693/ }}} - class DefaultOrderedDict(OrderedDict): """ @@ -350,7 +48,7 @@ class DefaultOrderedDict(OrderedDict): return type(self), args, None, None, self.items() def copy(self): - return self.__copy__() + return copy.copy(self) def __copy__(self): return type(self)(self.default_factory, self) diff --git a/salt/utils/openstack/nova.py b/salt/utils/openstack/nova.py index 9b8a15264b8..4c737ed6c4a 100644 --- a/salt/utils/openstack/nova.py +++ b/salt/utils/openstack/nova.py @@ -196,7 +196,7 @@ class NovaServer: self.extra["password"] = password def __str__(self): - return self.__dict__ + return str(self.__dict__) def get_entry(dict_, key, value, raise_error=True): diff --git a/salt/utils/oset.py b/salt/utils/oset.py index fb1db32b4e9..3725306ea0c 100644 --- a/salt/utils/oset.py +++ b/salt/utils/oset.py @@ -111,7 +111,7 @@ class OrderedSet(MutableSet): def __contains__(self, key): return key in self.map - def add(self, key): # pylint: disable=arguments-differ + def add(self, key): # pylint: disable=arguments-differ,arguments-renamed """ Add `key` as an item to this OrderedSet, then return its index. @@ -164,7 +164,7 @@ class OrderedSet(MutableSet): del self.map[elem] return elem - def discard(self, key): # pylint: disable=arguments-differ + def discard(self, key): # pylint: disable=arguments-differ,arguments-renamed """ Remove an element. Do not raise an exception if absent. diff --git a/salt/utils/parsers.py b/salt/utils/parsers.py index df044de4241..fc2eabc9a24 100644 --- a/salt/utils/parsers.py +++ b/salt/utils/parsers.py @@ -14,7 +14,7 @@ import copy import getpass import logging -import optparse +import optparse # pylint: disable=deprecated-module import os import signal import sys diff --git a/salt/utils/path.py b/salt/utils/path.py index e940321446a..eec79d7ef7b 100644 --- a/salt/utils/path.py +++ b/salt/utils/path.py @@ -181,9 +181,11 @@ def which(exe=None): # The specified extension isn't valid, so we just assume it's part of the # filename and proceed to walk the pathext list else: - is_executable = lambda path, membership=res: is_executable_common( - path - ) and has_executable_ext(path, membership) + + def is_executable(path, membership=res): + return is_executable_common(path) and has_executable_ext( + path, membership + ) else: # in posix, there's no such thing as file extensions..only zuul diff --git a/salt/utils/pkg/__init__.py b/salt/utils/pkg/__init__.py index 7092e7a5c77..e57cf9db411 100644 --- a/salt/utils/pkg/__init__.py +++ b/salt/utils/pkg/__init__.py @@ -34,7 +34,7 @@ def clear_rtag(opts): if exc.errno != errno.ENOENT: # Using __str__() here to get the fully-formatted error message # (error number, error message, path) - log.warning("Encountered error removing rtag: %s", exc.__str__()) + log.warning("Encountered error removing rtag: %s", exc) def write_rtag(opts): @@ -47,7 +47,7 @@ def write_rtag(opts): with salt.utils.files.fopen(rtag_file, "w+"): pass except OSError as exc: - log.warning("Encountered error writing rtag: %s", exc.__str__()) + log.warning("Encountered error writing rtag: %s", exc) def check_refresh(opts, refresh=None): diff --git a/salt/utils/pkg/win.py b/salt/utils/pkg/win.py index fa013196420..841ebef5145 100644 --- a/salt/utils/pkg/win.py +++ b/salt/utils/pkg/win.py @@ -826,7 +826,7 @@ class WinSoftware: Returns: str: Package Id """ - return self.__next__() + return next(self) def get(self, pkg_id, default_value=None): """ @@ -849,7 +849,7 @@ class WinSoftware: return 1 if Version(ver1) > Version(ver2) else -1 @staticmethod - def __latest_to_oldest_version(ver1, ver2): + def __latest_to_oldest_version(ver1, ver2): # pylint: disable=unused-private-member """ Used for sorting version numbers, latest to oldest """ diff --git a/salt/utils/preseed.py b/salt/utils/preseed.py index 749b24dace4..3b1f6105950 100644 --- a/salt/utils/preseed.py +++ b/salt/utils/preseed.py @@ -25,7 +25,7 @@ def mksls(src, dst=None): continue comps = shlex.split(line) - if comps[0] not in ps_opts.keys(): + if comps[0] not in ps_opts: ps_opts[comps[0]] = {} cmds = comps[1].split("/") diff --git a/salt/utils/process.py b/salt/utils/process.py index 52dd19f8479..af2f4cc5b0f 100644 --- a/salt/utils/process.py +++ b/salt/utils/process.py @@ -592,7 +592,7 @@ class ProcessManager: # with the tree option will not be able to find them. return - for pid in self._process_map.copy().keys(): + for pid in self._process_map.copy(): try: os.kill(pid, signal_) except OSError as exc: @@ -944,7 +944,7 @@ class Process(multiprocessing.Process): "logging_config": self.__logging_config__, } - def __decorate_run(self, run_func): + def __decorate_run(self, run_func): # pylint: disable=unused-private-member @functools.wraps(run_func) def wrapped_run_func(): # Static after fork method, always needs to happen first diff --git a/salt/utils/psutil_compat.py b/salt/utils/psutil_compat.py deleted file mode 100644 index bd6656945cd..00000000000 --- a/salt/utils/psutil_compat.py +++ /dev/null @@ -1,111 +0,0 @@ -""" -Version agnostic psutil hack to fully support both old (<2.0) and new (>=2.0) -psutil versions. - -The old <1.0 psutil API is dropped in psutil 3.0 - -Should be removed once support for psutil <2.0 is dropped. (eg RHEL 6) - -Built off of http://grodola.blogspot.com/2014/01/psutil-20-porting.html -""" - -# No exception handling, as we want ImportError if psutil doesn't exist -import psutil # pylint: disable=3rd-party-module-not-gated - -if psutil.version_info >= (2, 0): - from psutil import * # pylint: disable=wildcard-import,unused-wildcard-import,3rd-party-module-not-gated -else: - # Import hack to work around bugs in old psutil's - # Psuedo "from psutil import *" - _globals = globals() - for attr in psutil.__all__: - _temp = __import__("psutil", globals(), locals(), [attr], 0) - try: - _globals[attr] = getattr(_temp, attr) - except AttributeError: - pass - - # Import functions not in __all__ - # pylint: disable=unused-import,3rd-party-module-not-gated - from psutil import disk_partitions, disk_usage - - # pylint: enable=unused-import,3rd-party-module-not-gated - # Alias new module functions - def boot_time(): - return psutil.BOOT_TIME - - def cpu_count(): - return psutil.NUM_CPUS - - # Alias renamed module functions - pids = psutil.get_pid_list - try: - users = psutil.get_users - except AttributeError: - users = lambda: (_ for _ in ()).throw( - NotImplementedError("Your psutil version is too old") - ) - - # Deprecated in 1.0.1, but not mentioned in blog post - if psutil.version_info < (1, 0, 1): - net_io_counters = psutil.network_io_counters() - - class Process(psutil.Process): # pylint: disable=no-init - # Reimplement overloaded getters/setters - # pylint: disable=arguments-differ - def cpu_affinity(self, *args, **kwargs): - if args or kwargs: - return self.set_cpu_affinity(*args, **kwargs) - else: - return self.get_cpu_affinity() - - def ionice(self, *args, **kwargs): - if args or kwargs: - return self.set_ionice(*args, **kwargs) - else: - return self.get_ionice() - - def nice(self, *args, **kwargs): - if args or kwargs: - return self.set_nice(*args, **kwargs) - else: - return self.get_nice() - - def rlimit(self, *args, **kwargs): - """ - set_rlimit and get_limit were not introduced until psutil v1.1.0 - """ - if psutil.version_info >= (1, 1, 0): - if args or kwargs: - return self.set_rlimit(*args, **kwargs) - else: - return self.get_rlimit() - else: - pass - - # pylint: enable=arguments-differ - - # Alias renamed Process functions - _PROCESS_FUNCTION_MAP = { - "children": "get_children", - "connections": "get_connections", - "cpu_percent": "get_cpu_percent", - "cpu_times": "get_cpu_times", - "io_counters": "get_io_counters", - "memory_info": "get_memory_info", - "memory_info_ex": "get_ext_memory_info", - "memory_maps": "get_memory_maps", - "memory_percent": "get_memory_percent", - "num_ctx_switches": "get_num_ctx_switches", - "num_fds": "get_num_fds", - "num_threads": "get_num_threads", - "open_files": "get_open_files", - "threads": "get_threads", - "cwd": "getcwd", - } - - for new, old in _PROCESS_FUNCTION_MAP.items(): - try: - setattr(Process, new, psutil.Process.__dict__[old]) - except KeyError: - pass diff --git a/salt/utils/reactor.py b/salt/utils/reactor.py index 2cbcd3a1ab5..0229738ec3c 100644 --- a/salt/utils/reactor.py +++ b/salt/utils/reactor.py @@ -313,6 +313,7 @@ class ReactWrap: Populate the client cache with an instance of the specified type """ reaction_type = low["state"] + # pylint: disable=unsupported-membership-test,unsupported-assignment-operation if reaction_type not in self.client_cache: log.debug("Reactor is populating %s client cache", reaction_type) if reaction_type in ("runner", "wheel"): @@ -334,6 +335,7 @@ class ReactWrap: self.client_cache[reaction_type] = self.reaction_class[reaction_type]( self.opts["conf_file"] ) + # pylint: enable=unsupported-membership-test,unsupported-assignment-operation def run(self, low): """ diff --git a/salt/utils/ssdp.py b/salt/utils/ssdp.py index 40a0d82d067..587217414bd 100644 --- a/salt/utils/ssdp.py +++ b/salt/utils/ssdp.py @@ -157,7 +157,10 @@ class SSDPFactory(SSDPBase): :return: """ tries = 0 - slp_time = lambda: 0.5 / random.randint(10, 30) + + def slp_time(): + return 0.5 / random.randint(10, 30) + slp = slp_time() while tries < attempts: try: diff --git a/salt/utils/templates.py b/salt/utils/templates.py index 7623d49577b..d9204cf7154 100644 --- a/salt/utils/templates.py +++ b/salt/utils/templates.py @@ -673,7 +673,6 @@ def py(sfn, string=False, **kwargs): # pylint: disable=C0103 raise ImportError() mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) - # pylint: enable=no-member sys.modules[name] = mod # File templates need these set as __var__ diff --git a/salt/utils/verify.py b/salt/utils/verify.py index 02479b48c6a..4799e010e49 100644 --- a/salt/utils/verify.py +++ b/salt/utils/verify.py @@ -338,7 +338,7 @@ def check_user(user): try: if hasattr(os, "initgroups"): - os.initgroups(user, pwuser.pw_gid) # pylint: disable=minimum-python-version + os.initgroups(user, pwuser.pw_gid) else: os.setgroups(salt.utils.user.get_gid_list(user, include_default=False)) os.setgid(pwuser.pw_gid) @@ -429,7 +429,10 @@ def check_max_open_files(opts): # and the python binding http://timgolden.me.uk/pywin32-docs/win32file.html mof_s = mof_h = win32file._getmaxstdio() else: - mof_s, mof_h = resource.getrlimit(resource.RLIMIT_NOFILE) + + mof_s, mof_h = resource.getrlimit( # pylint: disable=used-before-assignment + resource.RLIMIT_NOFILE + ) accepted_keys_dir = os.path.join(opts.get("pki_dir"), "minions") accepted_count = len(os.listdir(accepted_keys_dir)) diff --git a/salt/utils/versions.py b/salt/utils/versions.py index 04dac7d4280..3469acfd54c 100644 --- a/salt/utils/versions.py +++ b/salt/utils/versions.py @@ -353,7 +353,10 @@ def version_cmp(pkg1, pkg2, ignore_epoch=False): version2, and 1 if version1 > version2. Return None if there was a problem making the comparison. """ - normalize = lambda x: str(x).split(":", 1)[-1] if ignore_epoch else str(x) + + def normalize(x): + return str(x).split(":", 1)[-1] if ignore_epoch else str(x) + pkg1 = normalize(pkg1) pkg2 = normalize(pkg2) diff --git a/salt/utils/vt.py b/salt/utils/vt.py index 4e81046820e..3ffe45af2bf 100644 --- a/salt/utils/vt.py +++ b/salt/utils/vt.py @@ -73,6 +73,7 @@ def setwinsize(child, rows=80, cols=80): Thank you for the shortcut PEXPECT """ + # pylint: disable=used-before-assignment TIOCSWINSZ = getattr(termios, "TIOCSWINSZ", -2146929561) if TIOCSWINSZ == 2148037735: # Same bits, but with sign. @@ -396,7 +397,7 @@ class Terminal: def _spawn(self): if not isinstance(self.args, str) and self.shell is True: self.args = " ".join(self.args) - parent, child = pty.openpty() + parent, child = pty.openpty() # pylint: disable=used-before-assignment err_parent, err_child = os.pipe() child_name = os.ttyname(child) proc = subprocess.Popen( # pylint: disable=subprocess-popen-preexec-fn diff --git a/salt/utils/win_network.py b/salt/utils/win_network.py index 1fae2ffe2f2..8d168595967 100644 --- a/salt/utils/win_network.py +++ b/salt/utils/win_network.py @@ -331,6 +331,7 @@ def _get_ip_wins_info(i_face): def _get_network_interfaces(): + # pylint: disable=used-before-assignment return NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() diff --git a/salt/utils/win_runas.py b/salt/utils/win_runas.py index 0b695aaad26..b50bc01ddb9 100644 --- a/salt/utils/win_runas.py +++ b/salt/utils/win_runas.py @@ -81,7 +81,8 @@ def create_env(user_token, inherit, timeout=1): break if env is not None: return env - raise exc + if exc is not None: + raise exc def runas(cmdLine, username, password=None, cwd=None): diff --git a/salt/utils/xmlutil.py b/salt/utils/xmlutil.py index 2c68afd67a6..cbcd26bbf49 100644 --- a/salt/utils/xmlutil.py +++ b/salt/utils/xmlutil.py @@ -331,7 +331,7 @@ def change_xml(doc, data, mapping): if new_value is not None: # We need to increment ids from arrays since xpath starts at 1 converters = { - p: (lambda n: n + 1) if f"[${p}]" in xpath else (lambda n: n) + p: ((lambda n: n + 1) if f"[${p}]" in xpath else (lambda n: n)) for p in placeholders } ctx = { diff --git a/salt/version.py b/salt/version.py index 82f1b6f3519..92e096566fb 100644 --- a/salt/version.py +++ b/salt/version.py @@ -59,7 +59,7 @@ class SaltVersionsInfo(type): _previous_release = None _next_release = None - # pylint: disable=bad-whitespace,multiple-spaces-before-operator + # pylint: disable=bad-whitespace # ----- Please refrain from fixing whitespace ----------------------------------> # The idea is to keep this readable. # ------------------------------------------------------------------------------- @@ -185,7 +185,7 @@ class SaltVersionsInfo(type): # <---- Please refrain from fixing whitespace ----------------------------------- # The idea is to keep this readable. # ------------------------------------------------------------------------------- - # pylint: enable=bad-whitespace,multiple-spaces-before-operator + # pylint: enable=bad-whitespace # fmt: on @classmethod @@ -872,7 +872,7 @@ def versions_information(include_salt_cloud=False, include_extensions=True): Report the versions of dependent software. """ py_info = [ - ("Python", sys.version.rsplit("\n")[0].strip()), + ("Python", sys.version.rsplit("\n", maxsplit=1)[0].strip()), ] salt_info = list(salt_information()) lib_info = list(dependency_information(include_salt_cloud)) diff --git a/setup.py b/setup.py index b81542d5db0..f0301701a31 100755 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ The setup script for salt """ -# pylint: disable=file-perms,resource-leakage +# pylint: disable=file-perms,resource-leakage,deprecated-module import setuptools # isort:skip import distutils.dist import glob @@ -181,7 +181,7 @@ else: def _parse_requirements_file(requirements_file): parsed_requirements = [] - with open(requirements_file) as rfh: + with open(requirements_file, encoding="utf-8") as rfh: for line in rfh.readlines(): line = line.strip() if not line or line.startswith(("#", "-r", "--")): @@ -260,7 +260,9 @@ class GenerateSaltSyspaths(Command): exit(1) # Write the system paths file - open(self.distribution.salt_syspaths_hardcoded_path, "w").write( + open( + self.distribution.salt_syspaths_hardcoded_path, "w", encoding="utf-8" + ).write( INSTALL_SYSPATHS_TEMPLATE.format( date=DATE, root_dir=self.distribution.salt_root_dir, @@ -308,9 +310,9 @@ class WriteSaltSshPackagingFile(Command): exit(1) # pylint: disable=E0602 - open(self.distribution.salt_ssh_packaging_file, "w").write( - "Packaged for Salt-SSH\n" - ) + open( + self.distribution.salt_ssh_packaging_file, "w", encoding="utf-8" + ).write("Packaged for Salt-SSH\n") # pylint: enable=E0602 @@ -463,7 +465,7 @@ class CloudSdist(Sdist): # pylint: disable=too-many-ancestors try: import requests - req = requests.get(url) + req = requests.get(url, timeout=120) if req.status_code == 200: script_contents = req.text.encode(req.encoding) else: @@ -482,10 +484,11 @@ class CloudSdist(Sdist): # pylint: disable=too-many-ancestors "Error code: {}".format(req.getcode()) ) try: - with open(deploy_path, "w") as fp_: + with open(deploy_path, "w", encoding="utf-8") as fp_: fp_.write(script_contents) except OSError as err: - log.error(f"Failed to write the updated script: {err}") + errmsg = f"Failed to write the updated script: {err}" + log.error(errmsg) # Let's the rest of the build command Sdist.run(self) diff --git a/tests/buildpackage.py b/tests/buildpackage.py index fcd3c734752..d431a3e432b 100644 --- a/tests/buildpackage.py +++ b/tests/buildpackage.py @@ -18,7 +18,7 @@ import re import shutil import subprocess import sys -from optparse import OptionGroup, OptionParser +from optparse import OptionGroup, OptionParser # pylint: disable=deprecated-module logging.QUIET = 0 logging.GARBAGE = 1 @@ -236,7 +236,7 @@ def build_centos(opts): log.info("Building CentOS RPM") log.info("Detecting major release") try: - with open("/etc/redhat-release") as fp_: + with open("/etc/redhat-release", encoding="utf-8") as fp_: redhat_release = fp_.read().strip() major_release = int(redhat_release.split()[2].split(".")[0]) except (ValueError, IndexError): @@ -322,9 +322,9 @@ def build_centos(opts): # Prepare SPEC file spec_path = os.path.join(opts.build_dir, "SPECS", "salt.spec") - with open(opts.spec_file) as spec: + with open(opts.spec_file, encoding="utf-8") as spec: spec_lines = spec.read().splitlines() - with open(spec_path, "w") as fp_: + with open(spec_path, "w", encoding="utf-8") as fp_: for line in spec_lines: if line.startswith("%global srcver "): line = f"%global srcver {salt_srcver}" diff --git a/tests/committer_parser.py b/tests/committer_parser.py index 914bc7c3dba..47175ca3c44 100644 --- a/tests/committer_parser.py +++ b/tests/committer_parser.py @@ -53,7 +53,7 @@ def parse_gitlog(filename=None): if not filename or filename == "-": fh = sys.stdin else: - fh = open(filename, "r+") + fh = open(filename, "r+", encoding="utf-8") try: commitcount = 0 diff --git a/tests/conftest.py b/tests/conftest.py index fbcf2901e27..8b7ea8056d8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,7 +34,7 @@ from tests.support.helpers import ( PRE_PYTEST_SKIP_REASON, get_virtualenv_binary_path, ) -from tests.support.pytest.helpers import * # pylint: disable=unused-wildcard-import +from tests.support.pytest.helpers import * # pylint: disable=unused-wildcard-import,wildcard-import from tests.support.runtests import RUNTIME_VARS from tests.support.sminion import check_required_sminion_attributes, create_sminion @@ -1556,7 +1556,7 @@ def from_filenames_collection_modifyitems(config, items): ): # In this case, this path is considered to be a file containing a line separated list # of files to consider - contents = properly_slashed_path.read_text() + contents = properly_slashed_path.read_text(encoding="utf-8") for sep in ("\r\n", "\\r\\n", "\\n"): contents = contents.replace(sep, "\n") for line in contents.split("\n"): diff --git a/tests/eventlisten.py b/tests/eventlisten.py index 8016f93bb8b..a5b8f53e635 100644 --- a/tests/eventlisten.py +++ b/tests/eventlisten.py @@ -5,7 +5,7 @@ what the sock_dir is. This script is a generic tool to test event output """ -import optparse +import optparse # pylint: disable=deprecated-module import os import pprint import time diff --git a/tests/integration/cli/test_custom_module.py b/tests/integration/cli/test_custom_module.py index ec8415424e7..0eba966e15c 100644 --- a/tests/integration/cli/test_custom_module.py +++ b/tests/integration/cli/test_custom_module.py @@ -33,6 +33,17 @@ import pytest from tests.support.case import SSHCase +pytestmark = [ + pytest.mark.skipif( + "grains['osfinger'] == 'Fedora Linux-39'", + reason="Fedora 39 ships with Python 3.12. Test can't run with system Python on 3.12", + # Actually, the problem is that the tornado we ship is not prepared for Python 3.12, + # and it imports `ssl` and checks if the `match_hostname` function is defined, which + # has been deprecated since Python 3.7, so, the logic goes into trying to import + # backports.ssl-match-hostname which is not installed on the system. + ) +] + @pytest.mark.skip_on_windows class SSHCustomModuleTest(SSHCase): diff --git a/tests/integration/cloud/clouds/test_oneandone.py b/tests/integration/cloud/clouds/test_oneandone.py index d0f5e30ee9f..148d9aafe53 100644 --- a/tests/integration/cloud/clouds/test_oneandone.py +++ b/tests/integration/cloud/clouds/test_oneandone.py @@ -6,15 +6,9 @@ import pytest from tests.integration.cloud.helpers.cloud_test_base import TIMEOUT, CloudTest -try: - from oneandone.client import OneAndOneService # pylint: disable=unused-import - - HAS_ONEANDONE = True -except ImportError: - HAS_ONEANDONE = False +pytest.importorskip("oneandone.client", reason="salt-cloud requires >= 1and1 1.2.0") -@pytest.mark.skipif(HAS_ONEANDONE is False, reason="salt-cloud requires >= 1and1 1.2.0") class OneAndOneTest(CloudTest): """ Integration tests for the 1and1 cloud provider diff --git a/tests/integration/cloud/clouds/test_vmware.py b/tests/integration/cloud/clouds/test_vmware.py index b997951c330..da7628d5e55 100644 --- a/tests/integration/cloud/clouds/test_vmware.py +++ b/tests/integration/cloud/clouds/test_vmware.py @@ -102,7 +102,7 @@ class VMWareTest(CloudTest): """ # salt-cloud -p my-instant-clone IC3 profile_name = "vmware-test-instant-clone" - self.run_cloud(f"-a remove_all_snapshots cloud-tests-template-base") + self.run_cloud("-a remove_all_snapshots cloud-tests-template-base") # create the instance log_format = "%(message)s" diff --git a/tests/integration/modules/test_cp.py b/tests/integration/modules/test_cp.py index 863db9a9d75..ef88590a9d5 100644 --- a/tests/integration/modules/test_cp.py +++ b/tests/integration/modules/test_cp.py @@ -595,7 +595,9 @@ class CPModuleTest(ModuleCase): @pytest.mark.slow_test def test_push(self): log_to_xfer = os.path.join(RUNTIME_VARS.TMP, uuid.uuid4().hex) - open(log_to_xfer, "w").close() # pylint: disable=resource-leakage + open( # pylint: disable=resource-leakage + log_to_xfer, "w", encoding="utf-8" + ).close() try: self.run_function("cp.push", [log_to_xfer]) tgt_cache_file = os.path.join( diff --git a/tests/integration/modules/test_ssh.py b/tests/integration/modules/test_ssh.py index 751a09db304..d46fba073d4 100644 --- a/tests/integration/modules/test_ssh.py +++ b/tests/integration/modules/test_ssh.py @@ -21,7 +21,7 @@ def check_status(): Check the status of Github for remote operations """ try: - return requests.get("https://github.com").status_code == 200 + return requests.get("https://github.com", timeout=60).status_code == 200 except Exception: # pylint: disable=broad-except return False diff --git a/tests/integration/netapi/rest_tornado/test_app.py b/tests/integration/netapi/rest_tornado/test_app.py index 2b020da4ac2..b701a1b7f89 100644 --- a/tests/integration/netapi/rest_tornado/test_app.py +++ b/tests/integration/netapi/rest_tornado/test_app.py @@ -67,7 +67,7 @@ class SaltnadoIntegrationTestsBase( def setUp(self): super().setUp() self.patched_environ = patched_environ(ASYNC_TEST_TIMEOUT="30") - self.patched_environ.__enter__() + self.patched_environ.__enter__() # pylint: disable=unnecessary-dunder-call self.addCleanup(self.patched_environ.__exit__) def tearDown(self): diff --git a/tests/integration/ssh/test_state.py b/tests/integration/ssh/test_state.py index 825dfbe7162..b808ac8070b 100644 --- a/tests/integration/ssh/test_state.py +++ b/tests/integration/ssh/test_state.py @@ -11,6 +11,17 @@ from saltfactories.utils.tempfiles import temp_file from tests.support.case import SSHCase from tests.support.runtests import RUNTIME_VARS +pytestmark = [ + pytest.mark.skipif( + "grains['osfinger'] == 'Fedora Linux-39'", + reason="Fedora 39 ships with Python 3.12. Test can't run with system Python on 3.12", + # Actually, the problem is that the tornado we ship is not prepared for Python 3.12, + # and it imports `ssl` and checks if the `match_hostname` function is defined, which + # has been deprecated since Python 3.7, so, the logic goes into trying to import + # backports.ssl-match-hostname which is not installed on the system. + ) +] + SSH_SLS = "ssh_state_tests" SSH_SLS_FILE = "/tmp/salt_test_file" diff --git a/tests/integration/states/test_ssh_auth.py b/tests/integration/states/test_ssh_auth.py index 46ffc9b4115..3e5bb291c28 100644 --- a/tests/integration/states/test_ssh_auth.py +++ b/tests/integration/states/test_ssh_auth.py @@ -29,7 +29,7 @@ class SSHAuthStateTests(ModuleCase, SaltReturnAssertsMixin): "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC3dd5ACsvJhnIOrn6bSOkX5" "KyVDpTYsVAaJj3AmEo6Fr5cHXJFJoJS+Ld8K5vCscPzuXashdYUdrhL1E5Liz" "bza+zneQ5AkJ7sn2NXymD6Bbra+infO4NgnQXbGMp/NyY65jbQGqJeQ081iEV" - f"YbDP2zXp6fmrqqmFCaakZfGRbVw== root" + "YbDP2zXp6fmrqqmFCaakZfGRbVw== root" ) key2 = ( "AAAAB3NzaC1yc2EAAAADAQABAAAAgQC7h77HyBPCUDONCs5bI/PrrPwyYJegl0" diff --git a/tests/minionswarm.py b/tests/minionswarm.py index 2ace3c7a7d5..dc2ed7179cd 100644 --- a/tests/minionswarm.py +++ b/tests/minionswarm.py @@ -7,7 +7,7 @@ on a single system to test scale capabilities # pylint: disable=resource-leakage import hashlib -import optparse +import optparse # pylint: disable=deprecated-module import os import random import shutil diff --git a/tests/modparser.py b/tests/modparser.py index 7e7882b1b9c..f0de1011437 100644 --- a/tests/modparser.py +++ b/tests/modparser.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python2 - +#!/usr/bin/env python +import argparse import modulefinder import os import pprint @@ -9,13 +9,6 @@ import sys import salt.utils.json import salt.utils.yaml -try: - import argparse # pylint: disable=minimum-python-version - - HAS_ARGPARSE = True -except ImportError: - HAS_ARGPARSE = False - def parse(): """ @@ -86,8 +79,6 @@ def scan(opts): if __name__ == "__main__": - if not HAS_ARGPARSE: - print("The argparse python module is required") opts = parse() try: scand = scan(opts) diff --git a/tests/pytests/functional/cache/test_etcd.py b/tests/pytests/functional/cache/test_etcd.py index 01ec44b4f4f..e69dcba8431 100644 --- a/tests/pytests/functional/cache/test_etcd.py +++ b/tests/pytests/functional/cache/test_etcd.py @@ -21,8 +21,8 @@ pytestmark = [ scope="module", params=(EtcdVersion.v2, EtcdVersion.v3_v2_mode), ids=etcd_version_ids, -) # pylint: disable=function-redefined -def etcd_version(request): +) +def etcd_version(request): # pylint: disable=function-redefined # The only parameter is True because the salt cache does not use # salt/utils/etcd_util.py and if coded for etcd v2 if request.param and not HAS_ETCD_V2: diff --git a/tests/pytests/functional/modules/test_data.py b/tests/pytests/functional/modules/test_data.py index 87f31c230ee..96520cbacbd 100644 --- a/tests/pytests/functional/modules/test_data.py +++ b/tests/pytests/functional/modules/test_data.py @@ -139,9 +139,9 @@ def test_has_key(data_module): ret = data_module.update("foo", "bar") assert ret - ret = data_module.has_key("foo") # pylint: disable=.has_key-is-deprecated-use-in + ret = data_module.has_key("foo") assert ret - ret = data_module.has_key("bar") # pylint: disable=.has_key-is-deprecated-use-in + ret = data_module.has_key("bar") assert not ret diff --git a/tests/pytests/functional/modules/test_system.py b/tests/pytests/functional/modules/test_system.py index e5ae735fdd3..f6a60b9e643 100644 --- a/tests/pytests/functional/modules/test_system.py +++ b/tests/pytests/functional/modules/test_system.py @@ -128,8 +128,8 @@ def _test_hwclock_sync(system, hwclock_has_compare): raise CompareTimeout for _ in range(2): + orig_handler = signal.signal(signal.SIGALRM, _alrm_handler) try: - orig_handler = signal.signal(signal.SIGALRM, _alrm_handler) signal.alarm(3) rpipeFd, wpipeFd = os.pipe() log.debug("Comparing hwclock to sys clock") diff --git a/tests/pytests/functional/states/file/test_append.py b/tests/pytests/functional/states/file/test_append.py index 6eeab13e287..1d5d8cd9bc2 100644 --- a/tests/pytests/functional/states/file/test_append.py +++ b/tests/pytests/functional/states/file/test_append.py @@ -145,13 +145,13 @@ def test_file_append_check_cmd(modules, state_tree, tmp_path): Test that check_cmd works for file.append and those states do not run. """ - sls_contents = f""" -append_in_file: - file.append: - - name: /tmp/test - - text: "appended text" - - check_cmd: - - "djasjahj" + sls_contents = """ + append_in_file: + file.append: + - name: /tmp/test + - text: "appended text" + - check_cmd: + - "djasjahj" """ with pytest.helpers.temp_file( "file-append-check-cmd.sls", sls_contents, state_tree diff --git a/tests/pytests/functional/states/file/test_replace.py b/tests/pytests/functional/states/file/test_replace.py index 48442bfb3e6..8ef1003ddd4 100644 --- a/tests/pytests/functional/states/file/test_replace.py +++ b/tests/pytests/functional/states/file/test_replace.py @@ -378,20 +378,20 @@ def test_file_replace_prerequired_issues_55775(modules, state_tree, tmp_path): assert managed_file.exists() -def test_file_replace_check_cmd(modules, state_tree, tmp_path): +def test_file_replace_check_cmd(modules, state_tree): """ Test that check_cmd works for file.replace and those states do not run. """ - sls_contents = f""" -replace_in_file: - file.replace: - - name: /tmp/test - - pattern: hi - - repl: "replacement text" - - append_if_not_found: True - - check_cmd: - - "djasjahj" + sls_contents = """ + replace_in_file: + file.replace: + - name: /tmp/test + - pattern: hi + - repl: "replacement text" + - append_if_not_found: True + - check_cmd: + - "djasjahj" """ with pytest.helpers.temp_file( "file-replace-check-cmd.sls", sls_contents, state_tree diff --git a/tests/pytests/functional/states/pkgrepo/test_debian.py b/tests/pytests/functional/states/pkgrepo/test_debian.py index 5452ecac1c4..822b4773f5e 100644 --- a/tests/pytests/functional/states/pkgrepo/test_debian.py +++ b/tests/pytests/functional/states/pkgrepo/test_debian.py @@ -614,7 +614,7 @@ def test_repo_absent_existing_repo_trailing_slash_uri( with subtests.test("Remove repo with trailing slash in URI"): # Write contents to file with trailing slash in URI - repo_file.write_text(f"{repo_content}\n") + repo_file.write_text(f"{repo_content}\n", encoding="utf-8") # Perform and validate removal ret = pkgrepo.absent(name=repo_content) assert ret.result @@ -630,7 +630,7 @@ def test_repo_absent_existing_repo_trailing_slash_uri( # Create a repo file that matches the URI but contains no architecture. # This should not be identified as a match for repo_content, and thus # the result of a state should be a no-op. - repo_file.write_text(f"deb {repo_uri} stable main\n") + repo_file.write_text(f"deb {repo_uri} stable main\n", encoding="utf-8") # Since this was a no-op, the state should have succeeded, made no # changes, and left the repo file in place. ret = pkgrepo.absent(name=repo_content) diff --git a/tests/pytests/functional/states/test_docker_container.py b/tests/pytests/functional/states/test_docker_container.py index 10e6509466d..39687b9a055 100644 --- a/tests/pytests/functional/states/test_docker_container.py +++ b/tests/pytests/functional/states/test_docker_container.py @@ -56,7 +56,7 @@ class Network: return ipaddress.ip_network(self.subnet) @_rand_indexes.default - def __rand_indexes(self): + def __rand_indexes(self): # pylint: disable=unused-private-member return random.sample( range(2, self.net.num_addresses - 1), self.net.num_addresses - 3 ) diff --git a/tests/pytests/functional/states/test_docker_network.py b/tests/pytests/functional/states/test_docker_network.py index 3890bd7ef06..1c9288e284b 100644 --- a/tests/pytests/functional/states/test_docker_network.py +++ b/tests/pytests/functional/states/test_docker_network.py @@ -46,7 +46,8 @@ class Network: "Indexing not supported for networks without a custom subnet" ) - def arg_map(self, arg_name): + @staticmethod + def arg_map(arg_name): ret = { "ipv4_address": "IPv4Address", "ipv6_address": "IPv6Address", diff --git a/tests/pytests/functional/states/test_pkg.py b/tests/pytests/functional/states/test_pkg.py index 13e316c7fae..deda8355ac8 100644 --- a/tests/pytests/functional/states/test_pkg.py +++ b/tests/pytests/functional/states/test_pkg.py @@ -507,7 +507,7 @@ def test_pkg_012_installed_with_wildcard_version(PKG_TARGETS, states, modules): ) expected_comment = ( - "All specified packages are already installed and are at the " "desired version" + "All specified packages are already installed and are at the desired version" ) assert ret.result is True assert ret.raw[next(iter(ret.raw))]["comment"] == expected_comment diff --git a/tests/pytests/functional/states/test_ssh_auth.py b/tests/pytests/functional/states/test_ssh_auth.py index 7ed7c7047fe..fea9a29df6c 100644 --- a/tests/pytests/functional/states/test_ssh_auth.py +++ b/tests/pytests/functional/states/test_ssh_auth.py @@ -45,7 +45,7 @@ def test_ssh_auth_config(tmp_path, system_user, state_tree): ssh_auth_state.manage( name="test", user=system_user.username, - source=f"salt://authorized", + source="salt://authorized", config=str(new_auth_file), ssh_keys=[""], ) diff --git a/tests/pytests/functional/test_crypt.py b/tests/pytests/functional/test_crypt.py index 0c8e90e82d6..b0cf862d641 100644 --- a/tests/pytests/functional/test_crypt.py +++ b/tests/pytests/functional/test_crypt.py @@ -7,6 +7,7 @@ import salt.crypt @pytest.mark.windows_whitelisted def test_generated_keys(tmp_path): - priv = salt.crypt.gen_keys(tmp_path, "aaa", 2048) - assert "\r" not in pathlib.Path(priv).read_text() - assert "\r" not in pathlib.Path(priv.replace(".pem", ".pub")).read_text() + priv = pathlib.Path(salt.crypt.gen_keys(tmp_path, "aaa", 2048)) + pub = priv.with_suffix(".pub") + assert "\r" not in priv.read_text(encoding="utf-8") + assert "\r" not in pub.read_text(encoding="utf-8") diff --git a/tests/pytests/integration/_logging/test_jid_logging.py b/tests/pytests/integration/_logging/test_jid_logging.py index 016bf89e104..96ba7697053 100644 --- a/tests/pytests/integration/_logging/test_jid_logging.py +++ b/tests/pytests/integration/_logging/test_jid_logging.py @@ -12,7 +12,7 @@ def test_jid_in_logs(caplog, salt_call_cli): """ Test JID in log_format """ - jid_formatted_str = DFLT_LOG_FMT_JID.split("%")[0] + jid_formatted_str = DFLT_LOG_FMT_JID.split("%", maxsplit=1)[0] formatter = logging.Formatter(fmt="%(jid)s %(message)s") with caplog.at_level(logging.DEBUG): previous_formatter = caplog.handler.formatter diff --git a/tests/pytests/integration/cli/test_batch.py b/tests/pytests/integration/cli/test_batch.py index 32ae60346f4..c9ebe2c5843 100644 --- a/tests/pytests/integration/cli/test_batch.py +++ b/tests/pytests/integration/cli/test_batch.py @@ -141,7 +141,9 @@ def test_batch_state_stopping_after_error( # Executing salt with batch: 1 and with failhard. It should stop after the first error. cmd = salt_cli.run( - "state.single" "test.fail_without_changes" "name=test_me", + "state.single", + "test.fail_without_changes", + "name=test_me", "-b 1", "--out=yaml", "--failhard", diff --git a/tests/pytests/integration/cli/test_salt.py b/tests/pytests/integration/cli/test_salt.py index 24b79a11b35..035c93dd427 100644 --- a/tests/pytests/integration/cli/test_salt.py +++ b/tests/pytests/integration/cli/test_salt.py @@ -255,7 +255,7 @@ def test_minion_65400(salt_cli, salt_minion, salt_minion_2, salt_master): Ensure correct exit status when salt CLI starts correctly. """ - state = f""" + state = """ custom_test_state: test.configurable_test_state: - name: example diff --git a/tests/pytests/integration/cli/test_syndic_eauth.py b/tests/pytests/integration/cli/test_syndic_eauth.py index a37127c3949..e1d159cdf91 100644 --- a/tests/pytests/integration/cli/test_syndic_eauth.py +++ b/tests/pytests/integration/cli/test_syndic_eauth.py @@ -523,7 +523,7 @@ def all_the_docker( except docker.errors.APIError as exc: # if the container isn't running, there's not thing we can do # at this point. - log.info(f"Docker failed removing /etc/salt: %s", exc) + log.info("Docker failed removing /etc/salt: %s", exc) @pytest.fixture( diff --git a/tests/pytests/integration/modules/state/test_state_test.py b/tests/pytests/integration/modules/state/test_state_test.py index 776350af1d9..c0c323170cc 100644 --- a/tests/pytests/integration/modules/state/test_state_test.py +++ b/tests/pytests/integration/modules/state/test_state_test.py @@ -136,7 +136,7 @@ def test_state_sls_id_test_state_test_post_run(salt_call_cli, testfile_path): true post the state already being run previously """ source = pathlib.Path(RUNTIME_VARS.BASE_FILES, "testfile") - testfile_path.write_text(source.read_text()) + testfile_path.write_text(source.read_text(encoding="utf-8"), encoding="utf-8") testfile_path.chmod(0o644) ret = salt_call_cli.run("state.sls", "sls-id-test") assert ret.returncode == 0 diff --git a/tests/pytests/integration/modules/test_virt.py b/tests/pytests/integration/modules/test_virt.py index 2ce6eed7357..a1ce0054189 100644 --- a/tests/pytests/integration/modules/test_virt.py +++ b/tests/pytests/integration/modules/test_virt.py @@ -419,13 +419,11 @@ class TestVirtMigrateTest: assert domains == [] def test_ssh_migration( - self, salt_cli, virt_minion_0, virt_minion_1, prep_virt, virt_domain, grains + self, salt_cli, virt_minion_0, virt_minion_1, prep_virt, virt_domain ): """ Test domain migration over SSH, TCP and TLS transport protocol """ - if grains["os"] == "VMware Photon OS" and grains["osmajorrelease"] == 3: - pytest.skip("Skipping this test on PhotonOS 3") ret = salt_cli.run("virt.list_active_vms", minion_tgt=virt_minion_0.id) assert ret.returncode == 0, ret diff --git a/tests/pytests/integration/netapi/test_ssh_client.py b/tests/pytests/integration/netapi/test_ssh_client.py index 9da5bb93d31..53c5910b476 100644 --- a/tests/pytests/integration/netapi/test_ssh_client.py +++ b/tests/pytests/integration/netapi/test_ssh_client.py @@ -8,6 +8,14 @@ from tests.support.mock import patch pytestmark = [ pytest.mark.slow_test, pytest.mark.requires_sshd_server, + pytest.mark.skipif( + "grains['osfinger'] == 'Fedora Linux-39'", + reason="Fedora 39 ships with Python 3.12. Test can't run with system Python on 3.12", + # Actually, the problem is that the tornado we ship is not prepared for Python 3.12, + # and it imports `ssl` and checks if the `match_hostname` function is defined, which + # has been deprecated since Python 3.7, so, the logic goes into trying to import + # backports.ssl-match-hostname which is not installed on the system. + ), ] @@ -137,13 +145,11 @@ def test_ssh_disabled(client, auth_creds): @pytest.mark.timeout_unless_on_windows(360) def test_shell_inject_ssh_priv( - client, salt_ssh_roster_file, rosters_dir, tmp_path, salt_auto_account, grains + client, salt_ssh_roster_file, rosters_dir, tmp_path, salt_auto_account ): """ Verify CVE-2020-16846 for ssh_priv variable """ - if grains["os"] == "VMware Photon OS" and grains["osmajorrelease"] == 3: - pytest.skip("Skipping problematic test on PhotonOS 3") # ZDI-CAN-11143 path = tmp_path / "test-11143" tgts = ["repo.saltproject.io", "www.zerodayinitiative.com"] diff --git a/tests/pytests/integration/sdb/test_etcd_db.py b/tests/pytests/integration/sdb/test_etcd_db.py index d981b222da7..3085dafb8ce 100644 --- a/tests/pytests/integration/sdb/test_etcd_db.py +++ b/tests/pytests/integration/sdb/test_etcd_db.py @@ -28,8 +28,8 @@ def etcd_static_port(sdb_etcd_port): # pylint: disable=function-redefined scope="module", params=(EtcdVersion.v2, EtcdVersion.v3_v2_mode), ids=etcd_version_ids, -) # pylint: disable=function-redefined -def etcd_version(request): +) +def etcd_version(request): # pylint: disable=function-redefined # The only parameter is True because the salt integration # configuration for the salt-master and salt-minion defaults # to v2. diff --git a/tests/pytests/integration/ssh/conftest.py b/tests/pytests/integration/ssh/conftest.py index 0ecc58a6d75..9b83df256b0 100644 --- a/tests/pytests/integration/ssh/conftest.py +++ b/tests/pytests/integration/ssh/conftest.py @@ -1,6 +1,18 @@ import pytest +@pytest.fixture(scope="package", autouse=True) +def _auto_skip_on_fedora_39(grains): + if grains["osfinger"] == "Fedora Linux-39": + pytest.skip( + "Fedora 39 ships with Python 3.12. Test can't run with system Python on 3.12" + # Actually, the problem is that the tornado we ship is not prepared for Python 3.12, + # and it imports `ssl` and checks if the `match_hostname` function is defined, which + # has been deprecated since Python 3.7, so, the logic goes into trying to import + # backports.ssl-match-hostname which is not installed on the system. + ) + + @pytest.fixture(scope="module") def state_tree(base_env_state_tree_root_dir): top_file = """ diff --git a/tests/pytests/integration/ssh/test_pre_flight.py b/tests/pytests/integration/ssh/test_pre_flight.py index c2fc14094e8..7dc56f37535 100644 --- a/tests/pytests/integration/ssh/test_pre_flight.py +++ b/tests/pytests/integration/ssh/test_pre_flight.py @@ -207,7 +207,7 @@ def test_ssh_pre_flight_script(salt_ssh_cli, caplog, _create_roster, tmp_path, a try: script = pathlib.Path.home() / "hacked" tmp_preflight = pathlib.Path("/tmp", "ssh_pre_flight.sh") - tmp_preflight.write_text(f"touch {script}") + tmp_preflight.write_text(f"touch {script}", encoding="utf-8") os.chown(tmp_preflight, account.info.uid, account.info.gid) ret = salt_ssh_cli.run("test.ping") assert not script.is_file() @@ -239,7 +239,7 @@ def test_ssh_pre_flight_perms(salt_ssh_cli, caplog, _create_roster, account): try: script = pathlib.Path("/tmp", "itworked") preflight = pathlib.Path("/ssh_pre_flight.sh") - preflight.write_text(f"touch {str(script)}") + preflight.write_text(f"touch {str(script)}", encoding="utf-8") tmp_preflight = pathlib.Path("/tmp", preflight.name) _custom_roster(salt_ssh_cli.roster_file, {"ssh_pre_flight": str(preflight)}) @@ -255,7 +255,8 @@ def test_ssh_pre_flight_perms(salt_ssh_cli, caplog, _create_roster, account): fi x=$(( $x + 1 )) done - """ + """, + encoding="utf-8", ) run_script.chmod(0o0777) # pylint: disable=W1509 diff --git a/tests/pytests/pkg/download/test_pkg_download.py b/tests/pytests/pkg/download/test_pkg_download.py index d25db84383f..b774d9fa047 100644 --- a/tests/pytests/pkg/download/test_pkg_download.py +++ b/tests/pytests/pkg/download/test_pkg_download.py @@ -8,7 +8,7 @@ import os import pathlib import shutil -import packaging +import packaging.version import pytest from pytestskipmarkers.utils import platform @@ -98,7 +98,7 @@ def get_salt_release(): salt_release = "3006.0rc2" if pkg_test_type == "download-pkgs": if packaging.version.parse(salt_release) < packaging.version.parse("3006.0rc1"): - log.warning(f"The salt release being tested, {salt_release!r} looks off.") + log.warning("The salt release being tested, %r looks off.", salt_release) return salt_release @@ -110,7 +110,9 @@ def get_repo_subpath_params(): latest_release = packaging.version.parse(latest_env_var) if current_release >= latest_release: log.debug( - f"Running the tests for the latest release since {str(current_release)} >= {str(latest_release)}" + "Running the tests for the latest release since %s >= %s", + current_release, + latest_release, ) params.append("latest") return params diff --git a/tests/pytests/pkg/integration/test_enabled_disabled.py b/tests/pytests/pkg/integration/test_enabled_disabled.py index b2293492701..d6ee20c6fd1 100644 --- a/tests/pytests/pkg/integration/test_enabled_disabled.py +++ b/tests/pytests/pkg/integration/test_enabled_disabled.py @@ -11,7 +11,7 @@ def test_services(install_salt, salt_cli, salt_minion): services_enabled = [] if install_salt.distro_id in ("ubuntu", "debian"): services_enabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"] - elif install_salt.distro_id in ("centos", "redhat", "amzn", "fedora"): + elif install_salt.distro_id in ("almalinux", "centos", "redhat", "amzn", "fedora"): services_disabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"] elif install_salt.distro_id == "photon": services_enabled = ["salt-master", "salt-minion", "salt-syndic", "salt-api"] diff --git a/tests/pytests/pkg/integration/test_pip_upgrade.py b/tests/pytests/pkg/integration/test_pip_upgrade.py index f306d99df70..da5b78a0585 100644 --- a/tests/pytests/pkg/integration/test_pip_upgrade.py +++ b/tests/pytests/pkg/integration/test_pip_upgrade.py @@ -48,7 +48,7 @@ def test_pip_install(install_salt, salt_call_cli): pytest.fail(f"Failed to find {dep} in the versions report output") if dep_version == installed_version: - log.warning(f"The {dep} dependency is already latest") + log.warning("The %s dependency is already latest", dep) else: found_new = True break @@ -86,7 +86,7 @@ def test_pip_install(install_salt, salt_call_cli): else: pytest.fail(f"Failed to find {dep} in the versions report output") finally: - log.info(f"Uninstalling {dep_version}") + log.info("Uninstalling %s", dep_version) assert salt_call_cli.run( "--local", "pip.uninstall", f"{dep}=={dep_version}" ) diff --git a/tests/pytests/pkg/integration/test_salt_user.py b/tests/pytests/pkg/integration/test_salt_user.py index 4538ce79adb..e1048b61cbf 100644 --- a/tests/pytests/pkg/integration/test_salt_user.py +++ b/tests/pytests/pkg/integration/test_salt_user.py @@ -188,7 +188,13 @@ def test_paths_log_rotation( ): pytest.skip("Package path ownership was changed in salt 3006.4") - if install_salt.distro_id not in ("centos", "redhat", "amzn", "fedora"): + if install_salt.distro_id not in ( + "almalinux", + "centos", + "redhat", + "amzn", + "fedora", + ): pytest.skip( "Only tests RedHat family packages till logrotation paths are resolved on Ubuntu/Debian, see issue 65231" ) @@ -296,7 +302,7 @@ def test_paths_log_rotation( for _path in log_files_list: log_path = pathlib.Path(_path) assert log_path.exists() - with log_path.open("a") as f: + with log_path.open("a", encoding="utf-8") as f: f.write("This is a log rotation test\n") # force log rotation diff --git a/tests/pytests/pkg/integration/test_systemd_config.py b/tests/pytests/pkg/integration/test_systemd_config.py index 6c530b51db2..8779827984c 100644 --- a/tests/pytests/pkg/integration/test_systemd_config.py +++ b/tests/pytests/pkg/integration/test_systemd_config.py @@ -14,6 +14,8 @@ def test_system_config(grains): """ if grains["os_family"] == "RedHat": if grains["osfinger"] in ( + "AlmaLinux-8", + "AlmaLinux-9", "CentOS Stream-8", "CentOS Linux-8", "CentOS Stream-9", diff --git a/tests/pytests/pkg/integration/test_version.py b/tests/pytests/pkg/integration/test_version.py index 713b73d78eb..1c193a882ab 100644 --- a/tests/pytests/pkg/integration/test_version.py +++ b/tests/pytests/pkg/integration/test_version.py @@ -125,8 +125,14 @@ def test_compare_pkg_versions_redhat_rc(version, install_salt): package of the same version. For example, v3004~rc1 should be less than v3004. """ - # It'd be nice to tests photon too but rpmdev-vercmp is not installed. - if install_salt.distro_id not in ("centos", "redhat", "amzn", "fedora"): + if install_salt.distro_id not in ( + "almalinux", + "centos", + "redhat", + "amzn", + "fedora", + "photon", + ): pytest.skip("Only tests rpm packages") pkg = [x for x in install_salt.pkgs if "rpm" in x] diff --git a/tests/pytests/scenarios/blackout/conftest.py b/tests/pytests/scenarios/blackout/conftest.py index dd025aa0d74..a75c20f30ed 100644 --- a/tests/pytests/scenarios/blackout/conftest.py +++ b/tests/pytests/scenarios/blackout/conftest.py @@ -46,7 +46,7 @@ class BlackoutPillar: self.minion_1_pillar.write_text(pillar_contents) self.refresh_pillar(exiting_blackout=False) self.in_blackout = True - return self.__enter__() + return self.__enter__() # pylint: disable=unnecessary-dunder-call def exit_blackout(self): if self.in_blackout: diff --git a/tests/pytests/unit/beacons/test_network_info.py b/tests/pytests/unit/beacons/test_network_info.py index 5ea31605484..0e80637f7d7 100644 --- a/tests/pytests/unit/beacons/test_network_info.py +++ b/tests/pytests/unit/beacons/test_network_info.py @@ -45,7 +45,7 @@ def test_empty_config(): def test_network_info_equal(stub_net_io_counters): with patch( - "salt.utils.psutil_compat.net_io_counters", + "psutil.net_io_counters", MagicMock(return_value=stub_net_io_counters), ): config = [ @@ -91,7 +91,7 @@ def test_network_info_equal(stub_net_io_counters): def test_network_info_greater_than(stub_net_io_counters): with patch( - "salt.utils.psutil_compat.net_io_counters", + "psutil.net_io_counters", MagicMock(return_value=stub_net_io_counters), ): config = [ diff --git a/tests/pytests/unit/beacons/test_ps.py b/tests/pytests/unit/beacons/test_ps.py index da6baa2bc0b..aa869dc4535 100644 --- a/tests/pytests/unit/beacons/test_ps.py +++ b/tests/pytests/unit/beacons/test_ps.py @@ -41,7 +41,7 @@ def test_empty_config(): def test_ps_running(): with patch( - "salt.utils.psutil_compat.process_iter", autospec=True, spec_set=True + "psutil.process_iter", autospec=True, spec_set=True ) as mock_process_iter: mock_process_iter.return_value = [ FakeProcess(_name="salt-master", pid=3), @@ -58,7 +58,7 @@ def test_ps_running(): def test_ps_not_running(): with patch( - "salt.utils.psutil_compat.process_iter", autospec=True, spec_set=True + "psutil.process_iter", autospec=True, spec_set=True ) as mock_process_iter: mock_process_iter.return_value = [ FakeProcess(_name="salt-master", pid=3), diff --git a/tests/pytests/unit/beacons/test_salt_monitor.py b/tests/pytests/unit/beacons/test_salt_monitor.py index 1edf8be539d..e718c780e50 100644 --- a/tests/pytests/unit/beacons/test_salt_monitor.py +++ b/tests/pytests/unit/beacons/test_salt_monitor.py @@ -1,5 +1,3 @@ -# pylint: disable=E8231 -# Salt libs import pytest import salt.beacons.salt_monitor as salt_monitor diff --git a/tests/pytests/unit/channel/__init__.py b/tests/pytests/unit/channel/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/pytests/unit/channel/test_server.py b/tests/pytests/unit/channel/test_server.py new file mode 100644 index 00000000000..7e72f2f03d0 --- /dev/null +++ b/tests/pytests/unit/channel/test_server.py @@ -0,0 +1,43 @@ +import pytest + +import salt.channel.server as server + + +@pytest.fixture +def key_data(): + return [ + "-----BEGIN PUBLIC KEY-----", + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoe5QSDYRWKyknbVyRrIj", + "rm1ht5HgKzAVUber0x54+b/UgxTd1cqI6I+eDlx53LqZSH3G8Rd5cUh8LHoGedSa", + "E62vEiLAjgXa+RdgcGiQpYS8+Z2RvQJ8oIcZgO+2AzgBRHboNWHTYRRmJXCd3dKs", + "9tcwK6wxChR06HzGqaOTixAuQlegWbOTU+X4dXIbW7AnuQBt9MCib7SxHlscrqcS", + "cBrRvq51YP6cxPm/rZJdBqZhVrlghBvIpa45NApP5PherGi4AbEGYte4l+gC+fOA", + "osEBis1V27djPpIyQS4qk3XAPQg6CYQMDltHqA4Fdo0Nt7SMScxJhfH0r6zmBFAe", + "BQIDAQAB", + "-----END PUBLIC KEY-----", + ] + + +@pytest.mark.parametrize("linesep", ["\r\n", "\r", "\n"]) +def test_compare_keys(key_data, linesep): + src_key = linesep.join(key_data) + tgt_key = "\n".join(key_data) + assert server.ReqServerChannel.compare_keys(src_key, tgt_key) is True + + +@pytest.mark.parametrize("linesep", ["\r\n", "\r", "\n"]) +def test_compare_keys_newline_src(key_data, linesep): + src_key = linesep.join(key_data) + linesep + tgt_key = "\n".join(key_data) + assert src_key.endswith(linesep) + assert not tgt_key.endswith("\n") + assert server.ReqServerChannel.compare_keys(src_key, tgt_key) is True + + +@pytest.mark.parametrize("linesep", ["\r\n", "\r", "\n"]) +def test_compare_keys_newline_tgt(key_data, linesep): + src_key = linesep.join(key_data) + tgt_key = "\n".join(key_data) + "\n" + assert not src_key.endswith(linesep) + assert tgt_key.endswith("\n") + assert server.ReqServerChannel.compare_keys(src_key, tgt_key) is True diff --git a/tests/pytests/unit/cli/test_daemons.py b/tests/pytests/unit/cli/test_daemons.py index 3abe897ca52..c602de7b651 100644 --- a/tests/pytests/unit/cli/test_daemons.py +++ b/tests/pytests/unit/cli/test_daemons.py @@ -61,9 +61,7 @@ class LoggerMock: :return: """ for data in self.messages: - log_str = ( - data["message"] % data["args"] - ) # pylint: disable=incompatible-py3-code + log_str = data["message"] % data["args"] if (data["type"] == log_type or not log_type) and log_str.find(msg) > -1: return True diff --git a/tests/pytests/unit/client/ssh/test_ssh.py b/tests/pytests/unit/client/ssh/test_ssh.py index 030d3bb7ee6..9fc56165ff5 100644 --- a/tests/pytests/unit/client/ssh/test_ssh.py +++ b/tests/pytests/unit/client/ssh/test_ssh.py @@ -229,7 +229,7 @@ def test_update_targets_ip_address(opts): assert opts["tgt"] == user + host client._update_targets() assert opts["tgt"] == host - assert client.targets[host]["user"] == user.split("@")[0] + assert client.targets[host]["user"] == user.split("@", maxsplit=1)[0] def test_update_targets_dns(opts): @@ -245,7 +245,7 @@ def test_update_targets_dns(opts): assert opts["tgt"] == user + host client._update_targets() assert opts["tgt"] == host - assert client.targets[host]["user"] == user.split("@")[0] + assert client.targets[host]["user"] == user.split("@", maxsplit=1)[0] def test_update_targets_no_user(opts): @@ -282,7 +282,7 @@ def test_update_expand_target_dns(opts, roster): client._expand_target() client._update_targets() assert opts["tgt"] == host - assert client.targets[host]["user"] == user.split("@")[0] + assert client.targets[host]["user"] == user.split("@", maxsplit=1)[0] def test_parse_tgt(opts): @@ -298,7 +298,7 @@ def test_parse_tgt(opts): assert not opts.get("ssh_cli_tgt") client = ssh.SSH(opts) assert client.parse_tgt["hostname"] == host - assert client.parse_tgt["user"] == user.split("@")[0] + assert client.parse_tgt["user"] == user.split("@", maxsplit=1)[0] assert opts.get("ssh_cli_tgt") == user + host diff --git a/tests/pytests/unit/cloud/clouds/test_proxmox.py b/tests/pytests/unit/cloud/clouds/test_proxmox.py index 8aba387c372..811bddb6173 100644 --- a/tests/pytests/unit/cloud/clouds/test_proxmox.py +++ b/tests/pytests/unit/cloud/clouds/test_proxmox.py @@ -384,6 +384,7 @@ def test__authenticate_with_custom_port(): "https://proxmox.connection.url:9999/api2/json/access/ticket", verify=True, data={"username": ("fakeuser",), "password": "secretpassword"}, + timeout=120, ) diff --git a/tests/pytests/unit/cloud/test_map.py b/tests/pytests/unit/cloud/test_map.py index ce2999003e7..400c77398bc 100644 --- a/tests/pytests/unit/cloud/test_map.py +++ b/tests/pytests/unit/cloud/test_map.py @@ -101,12 +101,10 @@ def salt_cloud_config_file(salt_master_factory): # The cloud map merge uses python's multiprocessing manager which authenticates using HMAC and MD5 @pytest.mark.skip_on_fips_enabled_platform -def test_cloud_map_merge_conf(salt_cloud_config_file, grains): +def test_cloud_map_merge_conf(salt_cloud_config_file): """ Ensure that nested values can be selectivly overridden in a map file """ - if grains["os"] == "VMware Photon OS" and grains["osmajorrelease"] == 3: - pytest.skip("Test hangs on PhotonOS 3") with patch( "salt.config.check_driver_dependencies", MagicMock(return_value=True) ), patch("salt.cloud.Map.read", MagicMock(return_value=EXAMPLE_MAP)): diff --git a/tests/pytests/unit/daemons/masterapi/test_remote_funcs.py b/tests/pytests/unit/daemons/masterapi/test_remote_funcs.py index 8151dcaf006..99821a8f54a 100644 --- a/tests/pytests/unit/daemons/masterapi/test_remote_funcs.py +++ b/tests/pytests/unit/daemons/masterapi/test_remote_funcs.py @@ -42,7 +42,7 @@ def test_mine_get(funcs, tgt_type_key="tgt_type"): funcs.cache.store("minions/webserver", "mine", dict(ip_addr="2001:db8::1:3")) with patch( "salt.utils.minions.CkMinions._check_compound_minions", - MagicMock(return_value=(dict(minions=["webserver"], missing=[]))), + MagicMock(return_value=dict(minions=["webserver"], missing=[])), ): ret = funcs._mine_get( { @@ -81,7 +81,7 @@ def test_mine_get_dict_str(funcs, tgt_type_key="tgt_type"): ) with patch( "salt.utils.minions.CkMinions._check_compound_minions", - MagicMock(return_value=(dict(minions=["webserver"], missing=[]))), + MagicMock(return_value=dict(minions=["webserver"], missing=[])), ): ret = funcs._mine_get( { @@ -114,7 +114,7 @@ def test_mine_get_dict_list(funcs, tgt_type_key="tgt_type"): ) with patch( "salt.utils.minions.CkMinions._check_compound_minions", - MagicMock(return_value=(dict(minions=["webserver"], missing=[]))), + MagicMock(return_value=dict(minions=["webserver"], missing=[])), ): ret = funcs._mine_get( { diff --git a/tests/pytests/unit/fileserver/test_roots.py b/tests/pytests/unit/fileserver/test_roots.py index c1660280bc5..c6a58136a3c 100644 --- a/tests/pytests/unit/fileserver/test_roots.py +++ b/tests/pytests/unit/fileserver/test_roots.py @@ -290,7 +290,7 @@ def test_find_file_not_in_root(tmp_state_tree): """ badfile = pathlib.Path(tmp_state_tree).parent / "bar" badfile.write_text("Bad file") - badpath = f"../bar" + badpath = "../bar" ret = roots.find_file(badpath) assert ret == {"path": "", "rel": ""} badpath = f"{tmp_state_tree / '..' / 'bar'}" @@ -304,7 +304,7 @@ def test_serve_file_not_in_root(tmp_state_tree): """ badfile = pathlib.Path(tmp_state_tree).parent / "bar" badfile.write_text("Bad file") - badpath = f"../bar" + badpath = "../bar" load = {"path": "salt://|..\\bar", "saltenv": "base", "loc": 0} fnd = { "path": f"{tmp_state_tree / '..' / 'bar'}", diff --git a/tests/pytests/unit/modules/file/test_file_line.py b/tests/pytests/unit/modules/file/test_file_line.py index 17f08cdf371..8e5fd022114 100644 --- a/tests/pytests/unit/modules/file/test_file_line.py +++ b/tests/pytests/unit/modules/file/test_file_line.py @@ -1633,7 +1633,7 @@ def test_line_insert_ensure_beforeafter_twolines_exists(tempfile_name): ) # pylint: enable=W1401 after, before = ( - file_content.split(os.linesep)[0], + file_content.split(os.linesep, maxsplit=1)[0], file_content.split(os.linesep)[2], ) diff --git a/tests/pytests/unit/modules/file/test_file_lsattr.py b/tests/pytests/unit/modules/file/test_file_lsattr.py index 232f2a22d4b..5e211b06428 100644 --- a/tests/pytests/unit/modules/file/test_file_lsattr.py +++ b/tests/pytests/unit/modules/file/test_file_lsattr.py @@ -79,9 +79,7 @@ def test_if_chattr_version_is_less_than_required_flags_should_ignore_extended(): ) with patch_has_ext, patch_run: actual = set(filemod.lsattr(fname)[fname]) - msg = "Actual: {!r} Expected: {!r}".format( - actual, expected - ) # pylint: disable=E1322 + msg = f"Actual: {actual!r} Expected: {expected!r}" assert actual == expected, msg @@ -107,9 +105,7 @@ def test_if_chattr_version_is_high_enough_then_extended_flags_should_be_returned ) with patch_has_ext, patch_run: actual = set(filemod.lsattr(fname)[fname]) - msg = "Actual: {!r} Expected: {!r}".format( - actual, expected - ) # pylint: disable=E1322 + msg = f"Actual: {actual!r} Expected: {expected!r}" assert actual == expected, msg @@ -135,7 +131,5 @@ def test_if_supports_extended_but_there_are_no_flags_then_none_should_be_returne ) with patch_has_ext, patch_run: actual = set(filemod.lsattr(fname)[fname]) - msg = "Actual: {!r} Expected: {!r}".format( - actual, expected - ) # pylint: disable=E1322 + msg = f"Actual: {actual!r} Expected: {expected!r}" assert actual == expected, msg diff --git a/tests/pytests/unit/modules/state/test_state.py b/tests/pytests/unit/modules/state/test_state.py index a5cb97f3c03..50f58fe487d 100644 --- a/tests/pytests/unit/modules/state/test_state.py +++ b/tests/pytests/unit/modules/state/test_state.py @@ -739,9 +739,7 @@ def test_top(): with patch.object(os.path, "join", mock): mock = MagicMock(return_value=True) with patch.object(state, "_set_retcode", mock): - assert state.top( - "reverse_top.sls " "exclude=exclude.sls" - ) + assert state.top("reverse_top.sls exclude=exclude.sls") def test_highstate(): @@ -779,7 +777,7 @@ def test_highstate(): with patch.object(state, "_filter_running", mock): mock = MagicMock(return_value=True) with patch.object(os.path, "join", mock): - with patch.object(state, "_set" "_retcode", mock): + with patch.object(state, "_set_retcode", mock): assert state.highstate(arg) @@ -883,11 +881,11 @@ def test_sls(): assert state.sls(arg, None, None, True, cache=True) MockState.HighState.flag = True - assert state.sls("core,edit" ".vim dev", None, None, True) + assert state.sls("core,edit.vim dev", None, None, True) MockState.HighState.flag = False with patch.object( - state, "_filter_" "running", return_value=True + state, "_filter_running", return_value=True ), patch.object(os.path, "join", return_value=True), patch.object( os, "umask", return_value=True ), patch.object( @@ -899,7 +897,7 @@ def test_sls(): ), patch( "salt.utils.files.fopen", mock_open() ): - assert state.sls("core,edit" ".vim dev", None, None, True) + assert state.sls("core,edit.vim dev", None, None, True) def test_get_test_value(): diff --git a/tests/pytests/unit/modules/test_ansiblegate.py b/tests/pytests/unit/modules/test_ansiblegate.py index 6201809c221..d9c0eb53a44 100644 --- a/tests/pytests/unit/modules/test_ansiblegate.py +++ b/tests/pytests/unit/modules/test_ansiblegate.py @@ -117,12 +117,11 @@ def test_ansible_module_call(): ANY, ], env=ANY, + capture_output=True, + timeout=1200, + text=True, check=True, shell=False, - stderr=-1, - stdout=-1, - timeout=1200, - universal_newlines=True, ) assert ret == {"completed": True} diff --git a/tests/pytests/unit/modules/test_cp.py b/tests/pytests/unit/modules/test_cp.py index 8618a6bf74f..d2e89bd79fa 100644 --- a/tests/pytests/unit/modules/test_cp.py +++ b/tests/pytests/unit/modules/test_cp.py @@ -41,7 +41,10 @@ def test__render_filenames_render_failed(): saltenv = "base" template = "jinja" file_data = "Remember to keep your files well salted." - mock_jinja = lambda *args, **kwargs: {"result": False, "data": file_data} + + def mock_jinja(*args, **kwargs): + return {"result": False, "data": file_data} + with patch.dict(templates.TEMPLATE_REGISTRY, {"jinja": mock_jinja}): with patch("salt.utils.files.fopen", mock_open(read_data=file_data)): pytest.raises( @@ -63,7 +66,10 @@ def test__render_filenames_success(): saltenv = "base" template = "jinja" file_data = "/srv/salt/biscuits" - mock_jinja = lambda *args, **kwargs: {"result": True, "data": file_data} + + def mock_jinja(*args, **kwargs): + return {"result": True, "data": file_data} + ret = (file_data, file_data) # salt.utils.files.fopen can only be mocked once with patch.dict(templates.TEMPLATE_REGISTRY, {"jinja": mock_jinja}): with patch("salt.utils.files.fopen", mock_open(read_data=file_data)): @@ -146,7 +152,8 @@ def test_push(): assert num_opens == 1, num_opens fh_ = m_open.filehandles[filename][0] assert fh_.read.call_count == 2, fh_.read.call_count - req_channel_factory_mock().__enter__().send.assert_called_once_with( + + req_channel_factory_mock().__enter__().send.assert_called_once_with( # pylint: disable=unnecessary-dunder-call dict( loc=fh_.tell(), # pylint: disable=resource-leakage cmd="_file_recv", diff --git a/tests/pytests/unit/modules/test_glassfish.py b/tests/pytests/unit/modules/test_glassfish.py index 0362d23fc8d..fa0022f5fe6 100644 --- a/tests/pytests/unit/modules/test_glassfish.py +++ b/tests/pytests/unit/modules/test_glassfish.py @@ -34,6 +34,7 @@ def test__api_get(): url="http://localhost:4848/management/domain/ThePath", verify=True, auth=None, + timeout=120, ) @@ -52,6 +53,7 @@ def test__api_post(): verify=True, auth=None, data='{"1": 1}', + timeout=120, ) @@ -70,4 +72,5 @@ def test__api_delete(): verify=True, auth=None, params={1: 1}, + timeout=120, ) diff --git a/tests/pytests/unit/modules/test_gpg.py b/tests/pytests/unit/modules/test_gpg.py index 591fdf73c08..c8b3bcac2c4 100644 --- a/tests/pytests/unit/modules/test_gpg.py +++ b/tests/pytests/unit/modules/test_gpg.py @@ -626,7 +626,9 @@ def test_export_public_key_to_file(gpghome): keyids="xxxxxxxxxxxxxxxx", output=exported_keyfile, bare=True ) assert ret == GPG_TEST_PUB_KEY - keyfile_contents = pathlib.Path(exported_keyfile).read_text() + keyfile_contents = pathlib.Path(exported_keyfile).read_text( + encoding="utf-8" + ) assert keyfile_contents == GPG_TEST_PUB_KEY @@ -751,7 +753,9 @@ def test_export_secret_key_to_file_with_gpg_passphrase_in_pillar(gpghome): True, passphrase=GPG_TEST_KEY_PASSPHRASE, ) - keyfile_contents = pathlib.Path(exported_keyfile).read_text() + keyfile_contents = pathlib.Path(exported_keyfile).read_text( + encoding="utf-8" + ) assert keyfile_contents == GPG_TEST_PRIV_KEY diff --git a/tests/pytests/unit/modules/test_hg.py b/tests/pytests/unit/modules/test_hg.py index c942066fe9a..6639154d374 100644 --- a/tests/pytests/unit/modules/test_hg.py +++ b/tests/pytests/unit/modules/test_hg.py @@ -105,9 +105,7 @@ def test_status_multiple(): with patch.dict( hg.__salt__, - { - "cmd.run_stdout": MagicMock(side_effect=side_effect), - }, + {"cmd.run_stdout": MagicMock(side_effect=side_effect)}, ): assert hg.status(["dir 0", "dir 1"]) == { "dir 0": {"added": ["file 0"]}, diff --git a/tests/pytests/unit/modules/test_mount.py b/tests/pytests/unit/modules/test_mount.py index b93017cb5e8..1147e6e2eff 100644 --- a/tests/pytests/unit/modules/test_mount.py +++ b/tests/pytests/unit/modules/test_mount.py @@ -416,8 +416,6 @@ def test_set_filesystems_with_data(tmp_sub_dir, config_file): Tests to verify set_filesystems reads and adjusts file /etc/filesystems correctly """ # Note AIX uses tabs in filesystems files, hence disable warings and errors for tabs and spaces - # pylint: disable=W8191 - # pylint: disable=E8101 config_filepath = str(tmp_sub_dir / "filesystems") with patch.dict(mount.__grains__, {"os": "AIX", "kernel": "AIX"}): mount.set_filesystems( diff --git a/tests/pytests/unit/modules/test_ps.py b/tests/pytests/unit/modules/test_ps.py index ba87bdccd4a..14a75446890 100644 --- a/tests/pytests/unit/modules/test_ps.py +++ b/tests/pytests/unit/modules/test_ps.py @@ -1,6 +1,7 @@ import time from collections import namedtuple +import psutil import pytest import salt.modules.ps @@ -10,8 +11,6 @@ import salt.utils.platform from salt.exceptions import CommandExecutionError, SaltInvocationError from tests.support.mock import MagicMock, Mock, call, patch -psutil = pytest.importorskip("salt.utils.psutil_compat") - # TestCase Exceptions are tested in tests/unit/modules/test_ps.py @@ -99,7 +98,7 @@ def test__status_when_process_is_found_with_matching_status_then_proc_info_shoul expected_result = [{"pid": 42, "name": "blerp"}] proc = sample_process with patch( - "salt.utils.psutil_compat.process_iter", + "psutil.process_iter", autospec=True, return_value=[ proc @@ -113,7 +112,7 @@ def test__status_when_process_is_found_with_matching_status_then_proc_info_shoul def test__status_when_no_matching_processes_then_no_results_should_be_returned(): expected_result = [] with patch( - "salt.utils.psutil_compat.process_iter", + "psutil.process_iter", autospec=True, return_value=[MagicMock(info={"status": "foo", "blerp": "whatever"})], ): @@ -127,7 +126,7 @@ def test__status_when_some_matching_processes_then_only_correct_info_should_be_r ): expected_result = [{"name": "blerp", "pid": 42}] with patch( - "salt.utils.psutil_compat.process_iter", + "psutil.process_iter", autospec=True, return_value=[ sample_process, @@ -140,9 +139,6 @@ def test__status_when_some_matching_processes_then_only_correct_info_should_be_r assert actual_result == expected_result -HAS_PSUTIL_VERSION = False - - STUB_CPU_TIMES = namedtuple("cputimes", "user nice system idle")(1, 2, 3, 4) STUB_CPU_TIMES_PERCPU = [ namedtuple("cputimes", "user nice system idle")(1, 2, 3, 4), @@ -207,9 +203,6 @@ def stub_user(): ) -if psutil.version_info >= (0, 6, 0): - HAS_PSUTIL_VERSION = True - STUB_PID_LIST = [0, 1, 2, 3] try: @@ -304,15 +297,15 @@ class DummyProcess: @pytest.fixture def mocked_proc(): - mocked_proc = MagicMock("salt.utils.psutil_compat.Process") + mocked_proc = MagicMock("psutil.Process") mocked_proc.name = Mock(return_value="test_mock_proc") mocked_proc.pid = Mock(return_value=9999999999) mocked_proc.cmdline = Mock( return_value=["test_mock_proc", "--arg", "--kwarg=value"] ) - with patch("salt.utils.psutil_compat.Process.send_signal"), patch( - "salt.utils.psutil_compat.process_iter", + with patch("psutil.Process.send_signal"), patch( + "psutil.process_iter", MagicMock(return_value=[mocked_proc]), ): yield mocked_proc @@ -429,7 +422,7 @@ def test__get_proc_username(): def test_get_pid_list(): - with patch("salt.utils.psutil_compat.pids", MagicMock(return_value=STUB_PID_LIST)): + with patch("psutil.pids", MagicMock(return_value=STUB_PID_LIST)): assert STUB_PID_LIST == ps.get_pid_list() @@ -437,12 +430,12 @@ def test_kill_pid(): cmdline = ["echo", "питон"] top_proc = DummyProcess(cmdline=cmdline) - with patch("salt.utils.psutil_compat.Process") as mock_process: + with patch("psutil.Process") as mock_process: mock_process.side_effect = psutil.NoSuchProcess(top_proc) ret = ps.kill_pid(0, signal=999) assert not ret - with patch("salt.utils.psutil_compat.Process") as send_signal_mock: + with patch("psutil.Process") as send_signal_mock: ps.kill_pid(0, signal=999) assert send_signal_mock.call_args == call(0) @@ -469,7 +462,7 @@ def test_pkill(mocked_proc): def test_pgrep(mocked_proc): with patch( - "salt.utils.psutil_compat.process_iter", + "psutil.process_iter", MagicMock(return_value=[mocked_proc]), ): assert mocked_proc.pid in (ps.pgrep(_get_proc_name(mocked_proc)) or []) @@ -481,7 +474,7 @@ def test_pgrep(mocked_proc): def test_pgrep_regex(mocked_proc): with patch( - "salt.utils.psutil_compat.process_iter", + "psutil.process_iter", MagicMock(return_value=[mocked_proc]), ): assert mocked_proc.pid in ( @@ -490,26 +483,22 @@ def test_pgrep_regex(mocked_proc): def test_cpu_percent(): - with patch("salt.utils.psutil_compat.cpu_percent", MagicMock(return_value=1)): + with patch("psutil.cpu_percent", MagicMock(return_value=1)): assert ps.cpu_percent() == 1 - with patch( - "salt.utils.psutil_compat.cpu_percent", MagicMock(return_value=(1, 1, 1, 1)) - ): + with patch("psutil.cpu_percent", MagicMock(return_value=(1, 1, 1, 1))): assert ps.cpu_percent(per_cpu=True) == [1, 1, 1, 1] - with patch("salt.utils.psutil_compat.cpu_percent", MagicMock(return_value=1)): + with patch("psutil.cpu_percent", MagicMock(return_value=1)): assert ps.cpu_percent(per_cpu=False) == 1 def test_cpu_times(): - with patch( - "salt.utils.psutil_compat.cpu_times", MagicMock(return_value=STUB_CPU_TIMES) - ): + with patch("psutil.cpu_times", MagicMock(return_value=STUB_CPU_TIMES)): assert {"idle": 4, "nice": 2, "system": 3, "user": 1} == ps.cpu_times() with patch( - "salt.utils.psutil_compat.cpu_times", + "psutil.cpu_times", MagicMock(return_value=STUB_CPU_TIMES_PERCPU), ): assert [ @@ -520,21 +509,9 @@ def test_cpu_times(): ] == ps.cpu_times(per_cpu=True) -@pytest.mark.skipif( - HAS_PSUTIL_VERSION is False, - reason="psutil 0.6.0 or greater is required for this test", -) def test_virtual_memory(): - with patch("salt.modules.ps.psutil.version_info", (0, 5, 9)): - with pytest.raises(CommandExecutionError) as exc: - ps.virtual_memory() - assert ( - exc.value.error - == "virtual_memory is only available in psutil 0.6.0 or greater" - ) - with patch( - "salt.utils.psutil_compat.virtual_memory", + "psutil.virtual_memory", MagicMock(return_value=STUB_VIRT_MEM), ): assert { @@ -546,22 +523,9 @@ def test_virtual_memory(): } == ps.virtual_memory() -@pytest.mark.skipif( - HAS_PSUTIL_VERSION is False, - reason="psutil 0.6.0 or greater is required for this test", -) def test_swap_memory(): - - with patch("salt.modules.ps.psutil.version_info", (0, 5, 9)): - with pytest.raises(CommandExecutionError) as exc: - ps.swap_memory() - assert ( - exc.value.error - == "swap_memory is only available in psutil 0.6.0 or greater" - ) - with patch( - "salt.utils.psutil_compat.swap_memory", + "psutil.swap_memory", MagicMock(return_value=STUB_SWAP_MEM), ): assert { @@ -576,7 +540,7 @@ def test_swap_memory(): def test_disk_partitions(): with patch( - "salt.utils.psutil_compat.disk_partitions", + "psutil.disk_partitions", MagicMock(return_value=[STUB_DISK_PARTITION]), ): assert { @@ -589,7 +553,7 @@ def test_disk_partitions(): def test_disk_usage(): with patch( - "salt.utils.psutil_compat.disk_usage", + "psutil.disk_usage", MagicMock(return_value=STUB_DISK_USAGE), ): assert { @@ -602,11 +566,11 @@ def test_disk_usage(): def test_disk_partition_usage(): with patch( - "salt.utils.psutil_compat.disk_partitions", + "psutil.disk_partitions", MagicMock(return_value=[STUB_DISK_PARTITION]), ): with patch( - "salt.utils.psutil_compat.disk_usage", + "psutil.disk_usage", MagicMock(return_value=STUB_DISK_USAGE), ): result = ps.disk_partition_usage()[0] @@ -624,7 +588,7 @@ def test_disk_partition_usage(): def test_network_io_counters(): with patch( - "salt.utils.psutil_compat.net_io_counters", + "psutil.net_io_counters", MagicMock(return_value=STUB_NETWORK_IO), ): assert { @@ -639,7 +603,7 @@ def test_network_io_counters(): } == ps.network_io_counters() with patch( - "salt.utils.psutil_compat.net_io_counters", + "psutil.net_io_counters", MagicMock(return_value=STUB_NETWORK_IO_PERNIC), ): assert { @@ -658,7 +622,7 @@ def test_network_io_counters(): def test_disk_io_counters(): with patch( - "salt.utils.psutil_compat.disk_io_counters", + "psutil.disk_io_counters", MagicMock(return_value=STUB_DISK_IO), ): assert { @@ -671,7 +635,7 @@ def test_disk_io_counters(): } == ps.disk_io_counters() with patch( - "salt.utils.psutil_compat.disk_io_counters", + "psutil.disk_io_counters", MagicMock(return_value=STUB_DISK_IO_PERDISK), ): assert { @@ -687,7 +651,7 @@ def test_disk_io_counters(): def test_get_users(stub_user): - with patch("salt.utils.psutil_compat.users", MagicMock(return_value=[stub_user])): + with patch("psutil.users", MagicMock(return_value=[stub_user])): assert { "terminal": "ttys000", "started": 0.0, @@ -710,8 +674,8 @@ def test_top(): cmdline = ["echo", "питон"] top_proc = DummyProcess(cmdline=cmdline) - with patch("salt.utils.psutil_compat.pids", return_value=[1]): - with patch("salt.utils.psutil_compat.Process") as mock_process: + with patch("psutil.pids", return_value=[1]): + with patch("psutil.Process") as mock_process: mock_process.side_effect = psutil.NoSuchProcess(top_proc) ret = ps.top(num_processes=1, interval=0) assert ret == [] @@ -752,8 +716,8 @@ def test_top(): ) zombie_mem_info = smem_info(0, 0, 0, 0, 0, 0, 0) - with patch("salt.utils.psutil_compat.pids", return_value=[1]): - with patch("salt.utils.psutil_compat.Process", return_value=top_proc): + with patch("psutil.pids", return_value=[1]): + with patch("psutil.Process", return_value=top_proc): with patch.object(top_proc, "cpu_times") as mock_cpu_times: with patch.object( top_proc, "memory_info", return_value=zombie_mem_info, create=True @@ -810,8 +774,8 @@ def test_top(): assert ret[0]["mem"] == expected_mem assert ret[0]["cpu"] == expected_cpu - with patch("salt.utils.psutil_compat.pids", return_value=[1]): - with patch("salt.utils.psutil_compat.Process", return_value=top_proc): + with patch("psutil.pids", return_value=[1]): + with patch("psutil.Process", return_value=top_proc): with patch.object(top_proc, "cpu_times") as mock_cpu_times: mock_cpu_times.side_effect = [ top_proc._cpu_times, @@ -820,8 +784,8 @@ def test_top(): ret = ps.top(num_processes=1, interval=0) assert ret == [] - with patch("salt.utils.psutil_compat.pids", return_value=[1]): - with patch("salt.utils.psutil_compat.Process", return_value=top_proc): + with patch("psutil.pids", return_value=[1]): + with patch("psutil.Process", return_value=top_proc): with patch.object(top_proc, "cpu_times") as mock_cpu_times: with patch.object( top_proc, "memory_info", create=True @@ -849,9 +813,9 @@ def test_top_zombie_process(): processes[1].cpu_times = raise_exception # Make sure psutil.pids only returns the above 3 pids - with patch("salt.utils.psutil_compat.pids", return_value=pids): + with patch("psutil.pids", return_value=pids): # Make sure we use our process list from above - with patch("salt.utils.psutil_compat.Process", side_effect=processes): + with patch("psutil.Process", side_effect=processes): result = ps.top(num_processes=1, interval=0) assert len(result) == 1 @@ -864,15 +828,15 @@ def test_status_when_no_status_is_provided_then_raise_invocation_error(): @pytest.mark.parametrize( "exc_type", ( - salt.utils.psutil_compat.AccessDenied(pid="9999", name="whatever"), - salt.utils.psutil_compat.NoSuchProcess(pid="42"), + psutil.AccessDenied(pid="9999", name="whatever"), + psutil.NoSuchProcess(pid="42"), ), ) def test_status_when_access_denied_from_psutil_it_should_CommandExecutionError( exc_type, ): with patch( - "salt.utils.psutil_compat.process_iter", + "psutil.process_iter", autospec=True, side_effect=exc_type, ): @@ -890,9 +854,9 @@ def test_status_when_no_filter_is_provided_then_raise_invocation_error(): def test_status_when_access_denied_from_psutil_then_raise_exception(): with patch( - "salt.utils.psutil_compat.process_iter", + "psutil.process_iter", autospec=True, - return_value=salt.utils.psutil_compat.AccessDenied(pid="9999", name="whatever"), + return_value=psutil.AccessDenied(pid="9999", name="whatever"), ): with pytest.raises(Exception) as general_issue: actual_result = salt.modules.ps.status(status="fnord") @@ -900,7 +864,7 @@ def test_status_when_access_denied_from_psutil_then_raise_exception(): ## This is commented out pending discussion on https://github.com/saltstack/salt/commit/2e5c3162ef87cca8a2c7b12ade7c7e1b32028f0a # @skipIf(not HAS_UTMP, "The utmp module must be installed to run test_get_users_utmp()") -# @patch('salt.utils.psutil_compat.get_users', new=MagicMock(return_value=None)) # This will force the function to use utmp +# @patch('psutil.get_users', new=MagicMock(return_value=None)) # This will force the function to use utmp # def test_get_users_utmp(): # pass @@ -1052,9 +1016,7 @@ def test_boot_time(): Testing boot_time function in the ps module """ - with patch( - "salt.utils.psutil_compat.boot_time", MagicMock(return_value=1691593290.0) - ): + with patch("psutil.boot_time", MagicMock(return_value=1691593290.0)): expected = 1691593290 ret = ps.boot_time() assert ret == expected @@ -1063,7 +1025,7 @@ def test_boot_time(): ret = ps.boot_time(time_format="%m/%d/%Y") assert ret == expected - with patch("salt.utils.psutil_compat.boot_time") as mock_boot_time: + with patch("psutil.boot_time") as mock_boot_time: mock_boot_time.side_effect = [AttributeError(), 1691593290.0] expected = 1691593290 ret = ps.boot_time() @@ -1075,13 +1037,13 @@ def test_num_cpus(): Testing num_cpus function in the ps module """ - with patch("salt.utils.psutil_compat.cpu_count") as mock_cpu_count: + with patch("psutil.cpu_count") as mock_cpu_count: mock_cpu_count.side_effect = AttributeError() - with patch("salt.utils.psutil_compat.NUM_CPUS", create=True, new=5): + with patch("psutil.NUM_CPUS", create=True, new=5): ret = ps.num_cpus() assert ret == 5 - with patch("salt.utils.psutil_compat.cpu_count") as mock_cpu_count: + with patch("psutil.cpu_count") as mock_cpu_count: mock_cpu_count.return_value = 5 ret = ps.num_cpus() assert ret == 5 @@ -1091,26 +1053,17 @@ def test_total_physical_memory(stub_memory_usage): """ Testing total_physical_memory function in the ps module """ - - with patch("salt.modules.ps.psutil.version_info", (0, 5, 9)): - with pytest.raises(CommandExecutionError) as exc: - ps.total_physical_memory() - assert ( - exc.value.error - == "virtual_memory is only available in psutil 0.6.0 or greater" - ) - - with patch("salt.utils.psutil_compat.virtual_memory") as mock_total_physical_memory: + with patch("psutil.virtual_memory") as mock_total_physical_memory: mock_total_physical_memory.side_effect = AttributeError() with patch( - "salt.utils.psutil_compat.TOTAL_PHYMEM", + "psutil.TOTAL_PHYMEM", create=True, new=stub_memory_usage.total, ): ret = ps.total_physical_memory() assert ret == 15722012672 - with patch("salt.utils.psutil_compat.virtual_memory") as mock_total_physical_memory: + with patch("psutil.virtual_memory") as mock_total_physical_memory: mock_total_physical_memory.return_value = stub_memory_usage ret = ps.total_physical_memory() assert ret == 15722012672 @@ -1231,7 +1184,7 @@ def test_proc_info_access_denied(): """ cmdline = ["echo", "питон"] dummy_proc = DummyProcess(cmdline=cmdline) - with patch("salt.utils.psutil_compat.Process") as mock_process: + with patch("psutil.Process") as mock_process: mock_process.side_effect = psutil.AccessDenied(dummy_proc) with pytest.raises(CommandExecutionError): salt.modules.ps.proc_info(pid=99, attrs=["username", "ppid"]) @@ -1244,7 +1197,7 @@ def test_proc_info_no_such_process(): """ cmdline = ["echo", "питон"] dummy_proc = DummyProcess(cmdline=cmdline) - with patch("salt.utils.psutil_compat.Process") as mock_process: + with patch("psutil.Process") as mock_process: mock_process.side_effect = psutil.NoSuchProcess(dummy_proc) with pytest.raises(CommandExecutionError): salt.modules.ps.proc_info(pid=99, attrs=["username", "ppid"]) @@ -1255,8 +1208,7 @@ def test_proc_info_attribute_error(): Testing proc_info function in the ps module when an AttributeError exception occurs """ - cmdline = ["echo", "питон"] - with patch("salt.utils.psutil_compat.Process") as mock_process: + with patch("psutil.Process") as mock_process: mock_process.side_effect = AttributeError() with pytest.raises(CommandExecutionError): salt.modules.ps.proc_info(pid=99, attrs=["username", "ppid"]) @@ -1273,20 +1225,3 @@ def test__virtual__no_psutil(): ) result = ps.__virtual__() assert result == expected - - -def test__virtual__wrong_version(): - with patch("salt.modules.ps.psutil.version_info", (0, 2, 9)): - expected = ( - False, - "The ps execution module cannot be loaded: the psutil python module version {}" - " is less than 0.3.0".format(psutil.version_info), - ) - result = ps.__virtual__() - assert result == expected - - -def test__virtual__correct_version(): - with patch("salt.modules.ps.psutil.version_info", (0, 3, 0)): - result = ps.__virtual__() - assert result diff --git a/tests/pytests/unit/modules/test_salt_version.py b/tests/pytests/unit/modules/test_salt_version.py index 4b7a7cd0731..6e3a09cbe78 100644 --- a/tests/pytests/unit/modules/test_salt_version.py +++ b/tests/pytests/unit/modules/test_salt_version.py @@ -29,8 +29,7 @@ def test_mocked_objects(): else: assert len(v) == 2 - sv = sv.__str__() - assert isinstance(sv, str) + assert isinstance(str(sv), str) with patch("salt.version.SaltStackVersion.LNAMES", {"neon": (2019, 8)}): sv = salt.version.SaltStackVersion.from_name("Neon") diff --git a/tests/pytests/unit/modules/test_solaris_shadow.py b/tests/pytests/unit/modules/test_solaris_shadow.py index 4cc99c6e983..85d7aa41fcd 100644 --- a/tests/pytests/unit/modules/test_solaris_shadow.py +++ b/tests/pytests/unit/modules/test_solaris_shadow.py @@ -29,7 +29,7 @@ skip_on_missing_pwd = pytest.mark.skipif( missing_pwd, reason="Has no pwd module for accessing /etc/password passwords" ) -# pylint: disable=singleton-comparison,comparison-to-True-should-be-if-cond-is-True-or-if-cond +# pylint: disable=singleton-comparison # TODO: A lot of the shadow functionality is common across solaris and Linux. # It would be possible to combine some of this into salt/utils -W. Werner, 2021-01-26 diff --git a/tests/pytests/unit/modules/test_win_powercfg.py b/tests/pytests/unit/modules/test_win_powercfg.py index 77475464e47..3fefad60804 100644 --- a/tests/pytests/unit/modules/test_win_powercfg.py +++ b/tests/pytests/unit/modules/test_win_powercfg.py @@ -167,7 +167,7 @@ def test_get_disk_timeout(query_output): calls = [ call("powercfg /getactivescheme", python_shell=False), call( - "powercfg /q 381b4222-f694-41f0-9685-ff5bb260df2e SUB_DISK" " DISKIDLE", + "powercfg /q 381b4222-f694-41f0-9685-ff5bb260df2e SUB_DISK DISKIDLE", python_shell=False, ), ] diff --git a/tests/pytests/unit/modules/test_zabbix.py b/tests/pytests/unit/modules/test_zabbix.py index 5c2f8fc7ee5..fd9fae8c1a6 100644 --- a/tests/pytests/unit/modules/test_zabbix.py +++ b/tests/pytests/unit/modules/test_zabbix.py @@ -407,7 +407,6 @@ def test_user_exists(conn_args, set_zabbix_version, query_return, mock_login): """ module_return = True - # pylint: disable=E8128 query_return( { "jsonrpc": "2.0", @@ -464,7 +463,6 @@ def test_user_get(conn_args, set_zabbix_version, query_return, mock_login): "type": "3", } ] - # pylint: disable=E8128 query_return( { "jsonrpc": "2.0", @@ -547,7 +545,6 @@ def test_user_getmedia(conn_args, set_zabbix_version, query_return, mock_login): "active": "0", } ] - # pylint: disable=E8128 query_return( { "jsonrpc": "2.0", @@ -707,7 +704,6 @@ def test_user_list(conn_args, query_return, mock_login): "type": "1", }, ] - # pylint: disable=E8128 query_return( { "jsonrpc": "2.0", @@ -924,7 +920,6 @@ def test_usergroup_list(conn_args, query_return, mock_login): "users_status": "0", }, ] - # pylint: disable=E8128 query_return( { "jsonrpc": "2.0", diff --git a/tests/pytests/unit/modules/virt/conftest.py b/tests/pytests/unit/modules/virt/conftest.py index 6e1bfa539b0..20796f66451 100644 --- a/tests/pytests/unit/modules/virt/conftest.py +++ b/tests/pytests/unit/modules/virt/conftest.py @@ -39,7 +39,7 @@ class MappedResultMock(MagicMock): def __init__(self): def mapped_results(*args, **kwargs): - if args[0] not in self._instances.keys(): + if args[0] not in self._instances: raise virt.libvirt.libvirtError(f"Not found: {args[0]}") return self._instances[args[0]] diff --git a/tests/pytests/unit/modules/win_lgpo/test_admx_policies.py b/tests/pytests/unit/modules/win_lgpo/test_admx_policies.py index 1e34ffc4612..77aba9ebea4 100644 --- a/tests/pytests/unit/modules/win_lgpo/test_admx_policies.py +++ b/tests/pytests/unit/modules/win_lgpo/test_admx_policies.py @@ -84,7 +84,7 @@ def lgpo_bin(): # download lgpo.zip log.debug("Downloading LGPO.exe from Microsoft") url = "https://download.microsoft.com/download/8/5/C/85C25433-A1B0-4FFA-9429-7E023E7DA8D8/LGPO.zip" - r = requests.get(url) + r = requests.get(url, timeout=60) with salt.utils.files.fopen(zip_file, "wb") as f: f.write(r.content) # extract zip diff --git a/tests/pytests/unit/pillar/test_consul_pillar.py b/tests/pytests/unit/pillar/test_consul_pillar.py index 430f7aa5e43..b37d5f7876e 100644 --- a/tests/pytests/unit/pillar/test_consul_pillar.py +++ b/tests/pytests/unit/pillar/test_consul_pillar.py @@ -54,9 +54,7 @@ def configure_loader_modules(): def test_connection(base_pillar_data): - with patch.dict( - consul_pillar.__salt__, {"grains.get": MagicMock(return_value=({}))} - ): + with patch.dict(consul_pillar.__salt__, {"grains.get": MagicMock(return_value={})}): with patch.object( consul_pillar, "consul_fetch", @@ -71,9 +69,7 @@ def test_connection(base_pillar_data): def test_pillar_data(base_pillar_data): - with patch.dict( - consul_pillar.__salt__, {"grains.get": MagicMock(return_value=({}))} - ): + with patch.dict(consul_pillar.__salt__, {"grains.get": MagicMock(return_value={})}): with patch.object( consul_pillar, "consul_fetch", @@ -90,9 +86,7 @@ def test_pillar_data(base_pillar_data): def test_blank_root(base_pillar_data): - with patch.dict( - consul_pillar.__salt__, {"grains.get": MagicMock(return_value=({}))} - ): + with patch.dict(consul_pillar.__salt__, {"grains.get": MagicMock(return_value={})}): with patch.object( consul_pillar, "consul_fetch", @@ -104,9 +98,7 @@ def test_blank_root(base_pillar_data): def test_pillar_nest(base_pillar_data): - with patch.dict( - consul_pillar.__salt__, {"grains.get": MagicMock(return_value=({}))} - ): + with patch.dict(consul_pillar.__salt__, {"grains.get": MagicMock(return_value={})}): with patch.object( consul_pillar, "consul_fetch", @@ -122,9 +114,7 @@ def test_pillar_nest(base_pillar_data): def test_value_parsing(base_pillar_data): - with patch.dict( - consul_pillar.__salt__, {"grains.get": MagicMock(return_value=({}))} - ): + with patch.dict(consul_pillar.__salt__, {"grains.get": MagicMock(return_value={})}): with patch.object( consul_pillar, "consul_fetch", @@ -137,9 +127,7 @@ def test_value_parsing(base_pillar_data): def test_non_expansion(base_pillar_data): - with patch.dict( - consul_pillar.__salt__, {"grains.get": MagicMock(return_value=({}))} - ): + with patch.dict(consul_pillar.__salt__, {"grains.get": MagicMock(return_value={})}): with patch.object( consul_pillar, "consul_fetch", diff --git a/tests/pytests/unit/proxy/test_napalm.py b/tests/pytests/unit/proxy/test_napalm.py index 93b849a65a8..dbf108b6977 100644 --- a/tests/pytests/unit/proxy/test_napalm.py +++ b/tests/pytests/unit/proxy/test_napalm.py @@ -277,7 +277,7 @@ def test_grains_refresh(test_opts): def test_fns(): ret = napalm_proxy.fns() - assert "details" in ret.keys() + assert "details" in ret def test_shutdown(test_opts): diff --git a/tests/pytests/unit/runners/test_asam.py b/tests/pytests/unit/runners/test_asam.py index 285138781b7..2f2f7d7e786 100644 --- a/tests/pytests/unit/runners/test_asam.py +++ b/tests/pytests/unit/runners/test_asam.py @@ -44,6 +44,7 @@ def test_add_platform(): auth=("TheUsername", "ThePassword"), data={"manual": "false"}, verify=True, + timeout=120, ) @@ -69,6 +70,7 @@ def test_remove_platform(): "Submit": "Yes", }, verify=True, + timeout=120, ) @@ -88,6 +90,7 @@ def test_list_platforms(): auth=("TheUsername", "ThePassword"), data={"manual": "false"}, verify=True, + timeout=120, ) @@ -107,4 +110,5 @@ def test_list_platform_sets(): auth=("TheUsername", "ThePassword"), data={"manual": "false"}, verify=True, + timeout=120, ) diff --git a/tests/pytests/unit/serializers/test_serializers.py b/tests/pytests/unit/serializers/test_serializers.py index 9721df6c0b4..3c27fe24cad 100644 --- a/tests/pytests/unit/serializers/test_serializers.py +++ b/tests/pytests/unit/serializers/test_serializers.py @@ -284,12 +284,12 @@ def test_sls_repr(): sls_obj = convert(OrderedDict([("foo", "bar"), ("baz", "qux")])) # ensure that repr and str are yaml friendly - assert sls_obj.__str__() == "{foo: bar, baz: qux}" - assert sls_obj.__repr__() == "{foo: bar, baz: qux}" + assert str(sls_obj) == "{foo: bar, baz: qux}" + assert repr(sls_obj) == "{foo: bar, baz: qux}" # ensure that repr and str are already quoted - assert sls_obj["foo"].__str__() == '"bar"' - assert sls_obj["foo"].__repr__() == '"bar"' + assert str(sls_obj["foo"]) == '"bar"' + assert repr(sls_obj["foo"]) == '"bar"' @pytest.mark.skipif(yamlex.available is False, reason=SKIP_MESSAGE.format("sls")) diff --git a/tests/pytests/unit/state/test_state_compiler.py b/tests/pytests/unit/state/test_state_compiler.py index e8a1fa71fd4..db241797326 100644 --- a/tests/pytests/unit/state/test_state_compiler.py +++ b/tests/pytests/unit/state/test_state_compiler.py @@ -11,7 +11,6 @@ import salt.state import salt.utils.files import salt.utils.platform from salt.exceptions import CommandExecutionError -from salt.utils.odict import OrderedDict from tests.support.mock import MagicMock, patch log = logging.getLogger(__name__) @@ -56,21 +55,21 @@ def test_render_error_on_invalid_requisite(minion_opts): """ with patch("salt.state.State._gather_pillar"): high_data = { - "git": OrderedDict( + "git": salt.state.HashableOrderedDict( [ ( "pkg", [ - OrderedDict( + salt.state.HashableOrderedDict( [ ( "require", [ - OrderedDict( + salt.state.HashableOrderedDict( [ ( "file", - OrderedDict( + salt.state.HashableOrderedDict( [("test1", "test")] ), ) @@ -89,7 +88,9 @@ def test_render_error_on_invalid_requisite(minion_opts): ] ) } - minion_opts["pillar"] = {"git": OrderedDict([("test1", "test")])} + minion_opts["pillar"] = { + "git": salt.state.HashableOrderedDict([("test1", "test")]) + } state_obj = salt.state.State(minion_opts) with pytest.raises(salt.exceptions.SaltRenderError): state_obj.call_high(high_data) @@ -720,13 +721,22 @@ def test_render_requisite_require_disabled(minion_opts): """ with patch("salt.state.State._gather_pillar"): high_data = { - "step_one": OrderedDict( + "step_one": salt.state.HashableOrderedDict( [ ( "test", [ - OrderedDict( - [("require", [OrderedDict([("test", "step_two")])])] + salt.state.HashableOrderedDict( + [ + ( + "require", + [ + salt.state.HashableOrderedDict( + [("test", "step_two")] + ) + ], + ) + ] ), "succeed_with_changes", {"order": 10000}, @@ -764,16 +774,20 @@ def test_render_requisite_require_in_disabled(minion_opts): "__env__": "base", "__sls__": "test.disable_require_in", }, - "step_two": OrderedDict( + "step_two": salt.state.HashableOrderedDict( [ ( "test", [ - OrderedDict( + salt.state.HashableOrderedDict( [ ( "require_in", - [OrderedDict([("test", "step_one")])], + [ + salt.state.HashableOrderedDict( + [("test", "step_one")] + ) + ], ) ] ), @@ -974,7 +988,7 @@ def test_mod_aggregate(minion_opts): "__sls__": "test.62439", "__env__": "base", "__id__": "sl", - "require_in": [OrderedDict([("file", "/tmp/foo")])], + "require_in": [salt.state.HashableOrderedDict([("file", "/tmp/foo")])], "order": 10002, "aggregate": True, "fun": "installed", @@ -1000,7 +1014,7 @@ def test_mod_aggregate(minion_opts): "__env__": "base", "__id__": "figlet", "__agg__": True, - "require": [OrderedDict([("file", "/tmp/foo")])], + "require": [salt.state.HashableOrderedDict([("file", "/tmp/foo")])], "order": 10001, "aggregate": True, "fun": "installed", @@ -1011,7 +1025,7 @@ def test_mod_aggregate(minion_opts): "__sls__": "test.62439", "__env__": "base", "__id__": "sl", - "require_in": [OrderedDict([("file", "/tmp/foo")])], + "require_in": [salt.state.HashableOrderedDict([("file", "/tmp/foo")])], "order": 10002, "aggregate": True, "fun": "installed", @@ -1026,7 +1040,7 @@ def test_mod_aggregate(minion_opts): "__sls__": "test.62439", "__env__": "base", "__id__": "sl", - "require_in": [OrderedDict([("file", "/tmp/foo")])], + "require_in": [salt.state.HashableOrderedDict([("file", "/tmp/foo")])], "order": 10002, "fun": "installed", "__agg__": True, @@ -1045,7 +1059,9 @@ def test_mod_aggregate(minion_opts): assert "require_in" in low_ret # Ensure all the requires from pkg states are in low - assert low_ret["require_in"] == [OrderedDict([("file", "/tmp/foo")])] + assert low_ret["require_in"] == [ + salt.state.HashableOrderedDict([("file", "/tmp/foo")]) + ] # Ensure that the require requisite from the # figlet state doesn't find its way into this state @@ -1190,7 +1206,7 @@ def test_load_modules_list(minion_opts): "__sls__": "test", "__env__": "base", "__id__": "nginx", - "provider": [OrderedDict([("cmd", "cmdmod")])], + "provider": [salt.state.HashableOrderedDict([("cmd", "cmdmod")])], "order": 10000, "fun": "installed", } @@ -1215,7 +1231,7 @@ def test_load_modules_dict(minion_opts): "__sls__": "test", "__env__": "base", "__id__": "nginx", - "provider": OrderedDict([("cmd", "test")]), + "provider": salt.state.HashableOrderedDict([("cmd", "test")]), "order": 10000, "fun": "installed", } diff --git a/tests/pytests/unit/states/test_host.py b/tests/pytests/unit/states/test_host.py index 5830747b115..35f57bf7731 100644 --- a/tests/pytests/unit/states/test_host.py +++ b/tests/pytests/unit/states/test_host.py @@ -256,11 +256,7 @@ def test_present(): ): ret = host.present(hostname, ip_str) assert ret["result"] is True - assert ( - ret["comment"] - == f"Host {hostname} ({ip_str}) already present" - in ret["comment"] - ) + assert f"Host {hostname} ({ip_str}) already present" in ret["comment"] assert ret["changes"] == {}, ret["changes"] assert add_host.mock_calls == [], add_host.mock_calls assert rm_host.mock_calls == [], rm_host.mock_calls diff --git a/tests/pytests/unit/transport/test_zeromq.py b/tests/pytests/unit/transport/test_zeromq.py index 01066334c94..beccfd3eea1 100644 --- a/tests/pytests/unit/transport/test_zeromq.py +++ b/tests/pytests/unit/transport/test_zeromq.py @@ -110,7 +110,7 @@ async def test_unclosed_request_client(minion_opts, io_loop): try: assert client._closing is False with pytest.warns(salt.transport.base.TransportWarning): - client.__del__() + client.__del__() # pylint: disable=unnecessary-dunder-call finally: client.close() @@ -128,6 +128,6 @@ async def test_unclosed_publish_client(minion_opts, io_loop): try: assert client._closing is False with pytest.warns(salt.transport.base.TransportWarning): - client.__del__() + client.__del__() # pylint: disable=unnecessary-dunder-call finally: client.close() diff --git a/tests/pytests/unit/utils/parsers/test_log_parsers.py b/tests/pytests/unit/utils/parsers/test_log_parsers.py index 737c8f2bb6c..fea2766b462 100644 --- a/tests/pytests/unit/utils/parsers/test_log_parsers.py +++ b/tests/pytests/unit/utils/parsers/test_log_parsers.py @@ -730,7 +730,7 @@ def test_log_created( """ testing_config.update({"log_file": str(log_file)}) log_file_name = str(log_file) - if log_file_name.split(os.sep)[-1] != "log_file": + if log_file_name.rsplit(os.sep, maxsplit=1)[-1] != "log_file": testing_config.update({log_file_name: str(log_file)}) instance = parser() diff --git a/tests/pytests/unit/utils/test_cloud.py b/tests/pytests/unit/utils/test_cloud.py index 340f226aedf..1c15f356280 100644 --- a/tests/pytests/unit/utils/test_cloud.py +++ b/tests/pytests/unit/utils/test_cloud.py @@ -58,18 +58,18 @@ def create_class(tmp_path): def set_password( self, servicename, username, password - ): # pylint: disable=arguments-differ + ): # pylint: disable=arguments-differ,arguments-renamed self.__storage.setdefault(servicename, {}).update({username: password}) return 0 def get_password( self, servicename, username - ): # pylint: disable=arguments-differ + ): # pylint: disable=arguments-differ,arguments-renamed return self.__storage.setdefault(servicename, {}).get(username) def delete_password( self, servicename, username - ): # pylint: disable=arguments-differ + ): # pylint: disable=arguments-differ,arguments-renamed self.__storage.setdefault(servicename, {}).pop(username, None) return 0 @@ -248,6 +248,7 @@ def test_run_psexec_command_cleanup_lingering_paexec(caplog): "MermaidMan", "BarnicleBoy", ) + # pylint: disable=no-value-for-parameter mock_client.return_value.cleanup = MagicMock(side_effect=CannotDelete()) cloud.run_psexec_command( @@ -474,7 +475,7 @@ def test_winrm_pinnned_version(): ): try: - import winrm + import winrm # pylint: disable=unused-import except ImportError: raise pytest.skip('The "winrm" python module is not installed in this env.') else: diff --git a/tests/pytests/unit/utils/test_data.py b/tests/pytests/unit/utils/test_data.py index bac2acb9dab..ff26e10d37c 100644 --- a/tests/pytests/unit/utils/test_data.py +++ b/tests/pytests/unit/utils/test_data.py @@ -16,8 +16,13 @@ from tests.support.unit import LOREM_IPSUM log = logging.getLogger(__name__) -_b = lambda x: x.encode("utf-8") -_s = lambda x: salt.utils.stringutils.to_str(x, normalize=True) + +def _b(x): + return x.encode("utf-8") + + +def _s(x): + return salt.utils.stringutils.to_str(x, normalize=True) @pytest.fixture @@ -568,7 +573,9 @@ def test_encode(get_test_data, get_BYTES, get_EGGS): None, [True, _b(get_EGGS), get_BYTES], ] - expected[11][_b("subdict")][_b("tuple")] = [ + expected[11][_b("subdict")][ # pylint: disable=unsupported-assignment-operation + _b("tuple") + ] = [ 123, _b("hello"), _b("world"), diff --git a/tests/pytests/unit/utils/test_msgpack.py b/tests/pytests/unit/utils/test_msgpack.py index 4faa9836a43..e15da262b00 100644 --- a/tests/pytests/unit/utils/test_msgpack.py +++ b/tests/pytests/unit/utils/test_msgpack.py @@ -26,9 +26,13 @@ def test_load_encoding(tmp_path): @pytest.mark.parametrize( - "version,encoding", [((2, 1, 3), False), ((1, 0, 0), False), ((0, 6, 2), True)] + "version", + [ + (2, 1, 3), + (1, 0, 0), + ], ) -def test_load_multiple_versions(version, encoding, tmp_path): +def test_load_multiple_versions(version, tmp_path): """ test when using msgpack on multiple versions that we only remove encoding on >= 1.0.0 @@ -47,24 +51,18 @@ def test_load_multiple_versions(version, encoding, tmp_path): with patch_dump, patch_load: with salt.utils.files.fopen(fname, "wb") as wfh: salt.utils.msgpack.dump(data, wfh, encoding="utf-8") - if encoding: - assert "encoding" in mock_dump.call_args.kwargs - else: - assert "encoding" not in mock_dump.call_args.kwargs + assert "encoding" not in mock_dump.call_args.kwargs with salt.utils.files.fopen(fname, "rb") as rfh: salt.utils.msgpack.load(rfh, **kwargs) - if encoding: - assert "encoding" in mock_load.call_args.kwargs - else: - assert "encoding" not in mock_load.call_args.kwargs + assert "encoding" not in mock_load.call_args.kwargs @pytest.mark.parametrize( "version,exp_kwargs", [ + ((1, 0, 0), {"raw": True, "strict_map_key": True, "use_bin_type": True}), ((0, 6, 0), {"raw": True, "strict_map_key": True, "use_bin_type": True}), - ((0, 5, 2), {"raw": True, "use_bin_type": True}), ], ) def test_sanitize_msgpack_kwargs(version, exp_kwargs): @@ -80,12 +78,8 @@ def test_sanitize_msgpack_kwargs(version, exp_kwargs): @pytest.mark.parametrize( "version,exp_kwargs", [ + ((2, 0, 0), {"raw": True, "strict_map_key": True, "use_bin_type": True}), ((1, 0, 0), {"raw": True, "strict_map_key": True, "use_bin_type": True}), - ( - (0, 6, 0), - {"strict_map_key": True, "use_bin_type": True, "encoding": "utf-8"}, - ), - ((0, 5, 2), {"use_bin_type": True, "encoding": "utf-8"}), ], ) def test_sanitize_msgpack_unpack_kwargs(version, exp_kwargs): diff --git a/tests/pytests/unit/utils/test_vt.py b/tests/pytests/unit/utils/test_vt.py index c31b25e623c..692bbf76f61 100644 --- a/tests/pytests/unit/utils/test_vt.py +++ b/tests/pytests/unit/utils/test_vt.py @@ -51,6 +51,6 @@ def test_log_sanitize(test_cmd, caplog): stream_stderr=False, ) with caplog.at_level(logging.DEBUG): - ret = term.recv() + term.recv() assert password not in caplog.text assert "******" in caplog.text diff --git a/tests/pytests/unit/wheel/test_file_roots.py b/tests/pytests/unit/wheel/test_file_roots.py index 5c8c54f23a5..4da2f359f2c 100644 --- a/tests/pytests/unit/wheel/test_file_roots.py +++ b/tests/pytests/unit/wheel/test_file_roots.py @@ -17,7 +17,7 @@ def _make_temp_root_file(root, *subpaths, binary=False, dir_only=False): full_path.write_bytes(content) else: content = str(full_path) - full_path.write_text(content) + full_path.write_text(content, encoding="utf-8") @pytest.fixture diff --git a/tests/salt-tcpdump.py b/tests/salt-tcpdump.py index 4a92966132b..c16e98a20e6 100644 --- a/tests/salt-tcpdump.py +++ b/tests/salt-tcpdump.py @@ -34,7 +34,7 @@ tcpdump "tcp[tcpflags] & tcp-syn != 0" and port 4506 and "tcp[tcpflags] & tcp-ac """ # pylint: disable=resource-leakage -import argparse # pylint: disable=minimum-python-version +import argparse import socket import sys import time @@ -124,7 +124,7 @@ class PCAPParser: packet_data = {"ip": {}, "tcp": {}} - (header, packet) = cap.next() # pylint: disable=incompatible-py3-code + (header, packet) = cap.next() eth_length, eth_protocol = self.parse_ether(packet) @@ -232,7 +232,7 @@ class SaltNetstat: """ Read the table of tcp connections & remove header """ - with open("/proc/net/tcp") as tcp_f: + with open("/proc/net/tcp", encoding="utf-8") as tcp_f: content = tcp_f.readlines() content.pop(0) return content diff --git a/tests/saltsh.py b/tests/saltsh.py index 64ace99cc3b..de87f55d9e7 100644 --- a/tests/saltsh.py +++ b/tests/saltsh.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -'''\ +''' Welcome to the Salt repl which exposes the execution environment of a minion in a pre-configured Python shell @@ -91,9 +91,11 @@ def get_salt_vars(): __pillar__ = {} # pylint: disable=invalid-name,unused-variable,possibly-unused-variable - JINJA = lambda x, **y: jinja2.Template(x).render( - grains=__grains__, salt=__salt__, opts=__opts__, pillar=__pillar__, **y - ) + def JINJA(x, **y): + return jinja2.Template(x).render( + grains=__grains__, salt=__salt__, opts=__opts__, pillar=__pillar__, **y + ) + # pylint: enable=invalid-name,unused-variable,possibly-unused-variable return locals() diff --git a/tests/support/pkg.py b/tests/support/pkg.py index eaf28eb4a3b..6df2dac0f63 100644 --- a/tests/support/pkg.py +++ b/tests/support/pkg.py @@ -111,7 +111,14 @@ class SaltPkgInstall: @pkg_mngr.default def _default_pkg_mngr(self): - if self.distro_id in ("centos", "redhat", "amzn", "fedora", "photon"): + if self.distro_id in ( + "almalinux", + "centos", + "redhat", + "amzn", + "fedora", + "photon", + ): return "yum" elif self.distro_id in ("ubuntu", "debian"): ret = self.proc.run("apt-get", "update") @@ -120,7 +127,14 @@ class SaltPkgInstall: @rm_pkg.default def _default_rm_pkg(self): - if self.distro_id in ("centos", "redhat", "amzn", "fedora", "photon"): + if self.distro_id in ( + "almalinux", + "centos", + "redhat", + "amzn", + "fedora", + "photon", + ): return "remove" elif self.distro_id in ("ubuntu", "debian"): return "purge" @@ -128,7 +142,14 @@ class SaltPkgInstall: @dbg_pkg.default def _default_dbg_pkg(self): dbg_pkg = None - if self.distro_id in ("centos", "redhat", "amzn", "fedora", "photon"): + if self.distro_id in ( + "almalinux", + "centos", + "redhat", + "amzn", + "fedora", + "photon", + ): dbg_pkg = "salt-debuginfo" elif self.distro_id in ("ubuntu", "debian"): dbg_pkg = "salt-dbg" @@ -144,7 +165,14 @@ class SaltPkgInstall: "salt-cloud", "salt-minion", ] - if self.distro_id in ("centos", "redhat", "amzn", "fedora", "photon"): + if self.distro_id in ( + "almalinux", + "centos", + "redhat", + "amzn", + "fedora", + "photon", + ): salt_pkgs.append("salt") elif self.distro_id in ("ubuntu", "debian"): salt_pkgs.append("salt-common") @@ -256,7 +284,7 @@ class SaltPkgInstall: self.install_dir / "salt-minion.exe" ).exists() and not self.relenv: log.debug( - f"Removing {(self.install_dir / 'salt-minion.exe')}" + "Removing %s", self.install_dir / "salt-minion.exe" ) (self.install_dir / "salt-minion.exe").unlink() @@ -524,13 +552,14 @@ class SaltPkgInstall: "3006.0" ) distro_name = self.distro_name - if distro_name == "centos" or distro_name == "fedora": + if distro_name in ("almalinux", "centos", "fedora"): distro_name = "redhat" root_url = "salt/py3/" if self.classic: root_url = "py3/" if self.distro_name in [ + "almalinux", "redhat", "centos", "amazon", @@ -646,7 +675,8 @@ class SaltPkgInstall: Pin: origin "repo.saltproject.io" Pin-Priority: 1001 """ - ) + ), + encoding="utf-8", ) cmd.append("--allow-downgrades") env = os.environ.copy() diff --git a/tests/support/pytest/etcd.py b/tests/support/pytest/etcd.py index ac7609444ed..2b8d6126d0b 100644 --- a/tests/support/pytest/etcd.py +++ b/tests/support/pytest/etcd.py @@ -59,7 +59,7 @@ def confirm_container_started(timeout_at, container): sleeptime = 1 while time.time() <= timeout_at: try: - response = requests.get(f"http://localhost:{etcd_port}/version") + response = requests.get(f"http://localhost:{etcd_port}/version", timeout=60) try: version = response.json() if "etcdserver" in version: diff --git a/tests/support/pytest/helpers.py b/tests/support/pytest/helpers.py index 4ddb0f2548a..871ddc872fe 100644 --- a/tests/support/pytest/helpers.py +++ b/tests/support/pytest/helpers.py @@ -704,13 +704,17 @@ class EntropyGenerator: log.info("The '%s' file is not avilable", kernel_entropy_file) return - self.current_entropy = int(kernel_entropy_file.read_text().strip()) + self.current_entropy = int( + kernel_entropy_file.read_text(encoding="utf-8").strip() + ) log.info("Available Entropy: %s", self.current_entropy) if not kernel_poolsize_file.exists(): log.info("The '%s' file is not avilable", kernel_poolsize_file) else: - self.current_poolsize = int(kernel_poolsize_file.read_text().strip()) + self.current_poolsize = int( + kernel_poolsize_file.read_text(encoding="utf-8").strip() + ) log.info("Entropy Poolsize: %s", self.current_poolsize) # Account for smaller poolsizes using BLAKE2s if self.current_poolsize == 256: @@ -736,7 +740,9 @@ class EntropyGenerator: raise pytest.skip.Exception(message, _use_item_location=True) raise pytest.fail(message) subprocess.run([rngd, "-r", "/dev/urandom"], shell=False, check=True) - self.current_entropy = int(kernel_entropy_file.read_text().strip()) + self.current_entropy = int( + kernel_entropy_file.read_text(encoding="utf-8").strip() + ) log.info("Available Entropy: %s", self.current_entropy) if self.current_entropy >= self.minimum_entropy: break @@ -771,7 +777,9 @@ class EntropyGenerator: check=True, ) os.unlink(target_file.name) - self.current_entropy = int(kernel_entropy_file.read_text().strip()) + self.current_entropy = int( + kernel_entropy_file.read_text(encoding="utf-8").strip() + ) log.info("Available Entropy: %s", self.current_entropy) if self.current_entropy >= self.minimum_entropy: break @@ -814,7 +822,9 @@ def change_cwd(path): @pytest.helpers.register def download_file(url, dest, auth=None): # NOTE the stream=True parameter below - with requests.get(url, allow_redirects=True, stream=True, auth=auth) as r: + with requests.get( + url, allow_redirects=True, stream=True, auth=auth, timeout=60 + ) as r: r.raise_for_status() with salt.utils.files.fopen(dest, "wb") as f: for chunk in r.iter_content(chunk_size=8192): diff --git a/tests/support/unit.py b/tests/support/unit.py index 88dd7808a22..7e2aefb43aa 100644 --- a/tests/support/unit.py +++ b/tests/support/unit.py @@ -159,7 +159,6 @@ class TestLoader(_TestLoader): class TestCase(_TestCase): - # pylint: disable=expected-an-indented-block-comment,too-many-leading-hastag-for-block-comment ## Commented out because it may be causing tests to hang ## at the end of the run # @@ -179,7 +178,6 @@ class TestCase(_TestCase): # print('\nWARNING: A misbehaving test has modified the working directory!\nThe test suite has reset the working directory ' # 'on tearDown() to {0}\n'.format(cls._cwd)) # cls._chdir_counter += 1 - # pylint: enable=expected-an-indented-block-comment,too-many-leading-hastag-for-block-comment def run(self, result=None): self._prerun_instance_attributes = dir(self) diff --git a/tests/support/win_installer.py b/tests/support/win_installer.py index a316fc8dfa7..b41586a6806 100644 --- a/tests/support/win_installer.py +++ b/tests/support/win_installer.py @@ -29,12 +29,15 @@ def download_and_verify(fp, name, repo=REPO): Download an installer and verify its contents. """ md5 = f"{name}.md5" - url = lambda x: f"{repo}/{x}" - resp = requests.get(url(md5)) + + def url(x): + return f"{repo}/{x}" + + resp = requests.get(url(md5), timeout=60) if resp.status_code != 200: raise Exception("Unable to fetch installer md5") installer_md5 = resp.text.strip().split()[0].lower() - resp = requests.get(url(name), stream=True) + resp = requests.get(url(name), stream=True, timeout=60) if resp.status_code != 200: raise Exception("Unable to fetch installer") md5hsh = hashlib.md5() diff --git a/tests/unit/ext/test_ipaddress.py b/tests/unit/ext/test_ipaddress.py index 95b3692ddce..d884ba3d2df 100644 --- a/tests/unit/ext/test_ipaddress.py +++ b/tests/unit/ext/test_ipaddress.py @@ -13,7 +13,7 @@ """Unittest for ipaddress module.""" -# pylint: disable=string-substitution-usage-error,pointless-statement,abstract-method,cell-var-from-loop +# pylint: disable=pointless-statement,abstract-method,cell-var-from-loop,unnecessary-dunder-call import contextlib import functools diff --git a/tests/unit/modules/test_boto_vpc.py b/tests/unit/modules/test_boto_vpc.py index 0841dd7ac0d..14490ac6cc2 100644 --- a/tests/unit/modules/test_boto_vpc.py +++ b/tests/unit/modules/test_boto_vpc.py @@ -5,15 +5,12 @@ import os.path import random import string -import pkg_resources # pylint: disable=3rd-party-module-not-gated import pytest -from pkg_resources import ( # pylint: disable=3rd-party-module-not-gated - DistributionNotFound, -) import salt.config import salt.loader import salt.modules.boto_vpc as boto_vpc +from salt._compat import importlib_metadata from salt.exceptions import CommandExecutionError, SaltInvocationError from salt.modules.boto_vpc import _maybe_set_name_tag, _maybe_set_tags from salt.utils.versions import Version @@ -117,8 +114,8 @@ def _get_moto_version(): return Version(str(moto.__version__)) except AttributeError: try: - return Version(pkg_resources.get_distribution("moto").version) - except DistributionNotFound: + return Version(importlib_metadata.version("moto")) + except importlib_metadata.PackageNotFoundError: return False diff --git a/tests/unit/modules/test_bsd_shadow.py b/tests/unit/modules/test_bsd_shadow.py index e60acb5172f..55c321e9866 100644 --- a/tests/unit/modules/test_bsd_shadow.py +++ b/tests/unit/modules/test_bsd_shadow.py @@ -12,6 +12,7 @@ from tests.support.unit import TestCase shadow = pytest.importorskip("salt.modules.bsd_shadow") + # Although bsd_shadow runs on NetBSD and OpenBSD as well, the mocks are # currently only designed for FreeBSD. diff --git a/tests/unit/modules/test_elasticsearch.py b/tests/unit/modules/test_elasticsearch.py index fc073f54d4d..4ab515e7d46 100644 --- a/tests/unit/modules/test_elasticsearch.py +++ b/tests/unit/modules/test_elasticsearch.py @@ -9,18 +9,14 @@ from salt.modules import elasticsearch from tests.support.mock import MagicMock, patch from tests.support.unit import TestCase -# Import elasticsearch exceptions -NO_ELASTIC = False -try: - from elasticsearch import NotFoundError, TransportError -except Exception: # pylint: disable=broad-except - NO_ELASTIC = True - - -@pytest.mark.skipif( - NO_ELASTIC, +_es_module = pytest.importorskip( + "elasticsearch", reason="Install elasticsearch-py before running Elasticsearch unit tests.", ) +NotFoundError = _es_module.NotFoundError +TransportError = _es_module.TransportError + + class ElasticsearchTestCase(TestCase): """ Test cases for salt.modules.elasticsearch diff --git a/tests/unit/modules/test_sysmod.py b/tests/unit/modules/test_sysmod.py index bd0d7073e8c..ce6210b19d7 100644 --- a/tests/unit/modules/test_sysmod.py +++ b/tests/unit/modules/test_sysmod.py @@ -112,15 +112,17 @@ class SysmodTestCase(TestCase, LoaderModuleMockMixin): cls.salt_dunder[func] = MockDocstringable(docstring) cls._docstrings[func] = docstring - module = func.split(".")[0] + module = func.split(".", maxsplit=1)[0] cls._statedocstrings[func] = docstring cls._statedocstrings[module] = f"docstring for {module}" - cls._modules.add(func.split(".")[0]) + cls._modules.add(func.split(".", maxsplit=1)[0]) docstring = f"docstring for {func}" mock = MockDocstringable(docstring) - mock.set_module_docstring("docstring for {}".format(func.split(".")[0])) + mock.set_module_docstring( + "docstring for {}".format(func.split(".", maxsplit=1)[0]) + ) Mockstate.State.states[func] = mock cls._modules = sorted(list(cls._modules)) diff --git a/tests/unit/modules/test_zcbuildout.py b/tests/unit/modules/test_zcbuildout.py index 503113f6d35..1e2d2836bfd 100644 --- a/tests/unit/modules/test_zcbuildout.py +++ b/tests/unit/modules/test_zcbuildout.py @@ -116,7 +116,7 @@ class Base(TestCase, LoaderModuleMockMixin): def setUp(self): if salt.utils.platform.is_darwin(): self.patched_environ = patched_environ(__cleanup__=["__PYVENV_LAUNCHER__"]) - self.patched_environ.__enter__() + self.patched_environ.__enter__() # pylint: disable=unnecessary-dunder-call self.addCleanup(self.patched_environ.__exit__) super().setUp() @@ -486,8 +486,8 @@ class BuildoutOnlineTestCase(Base): out = ret["out"] comment = ret["comment"] self.assertTrue(ret["status"]) - self.assertTrue("Creating directory" in out) - self.assertTrue("Installing a." in out) + self.assertIn("Creating directory", out) + self.assertIn("Installing a.", out) self.assertTrue(f"{self.py_st} bootstrap.py" in comment) self.assertTrue("buildout -c buildout.cfg" in comment) ret = buildout.buildout( @@ -496,17 +496,17 @@ class BuildoutOnlineTestCase(Base): outlog = ret["outlog"] out = ret["out"] comment = ret["comment"] - self.assertTrue("Installing single part: a" in outlog) - self.assertTrue("buildout -c buildout.cfg -N install a" in comment) - self.assertTrue("Installing b." in out) - self.assertTrue("Installing c." in out) + self.assertIn("Installing single part: a", outlog) + self.assertIn("buildout -c buildout.cfg -N install a", comment) + self.assertIn("Installing b.", out) + self.assertIn("Installing c.", out) ret = buildout.buildout( b_dir, parts=["a", "b", "c"], buildout_ver=2, newest=True, python=self.py_st ) outlog = ret["outlog"] out = ret["out"] comment = ret["comment"] - self.assertTrue("buildout -c buildout.cfg -n install a" in comment) + self.assertIn("buildout -c buildout.cfg -n install a", comment) # TODO: Is this test even still needed? @@ -533,8 +533,8 @@ class BuildoutAPITestCase(TestCase): out = ret["out"].decode("utf-8") for out in ["àé", "ççàé"]: - self.assertTrue(out in uretm["logs_by_level"]["info"]) - self.assertTrue(out in uretm["outlog_by_level"]) + self.assertIn(out, uretm["logs_by_level"]["info"]) + self.assertIn(out, uretm["outlog_by_level"]) def test_setup(self): buildout.LOG.clear() diff --git a/tests/unit/states/test_loop.py b/tests/unit/states/test_loop.py index ba100dfe663..ea3b0989d97 100644 --- a/tests/unit/states/test_loop.py +++ b/tests/unit/states/test_loop.py @@ -294,9 +294,7 @@ class LoopTestCaseNoEval(TestCase, LoaderModuleMockMixin): """ with patch.dict( salt.states.loop.__salt__, # pylint: disable=no-member - { - "foo.bar": MagicMock(side_effect=range(1, 7)) - }, # pylint: disable=incompatible-py3-code + {"foo.bar": MagicMock(side_effect=range(1, 7))}, ): self.assertDictEqual( salt.states.loop.until( @@ -312,9 +310,7 @@ class LoopTestCaseNoEval(TestCase, LoaderModuleMockMixin): with patch.dict( salt.states.loop.__salt__, # pylint: disable=no-member - { - "foo.bar": MagicMock(side_effect=range(1, 7)) - }, # pylint: disable=incompatible-py3-code + {"foo.bar": MagicMock(side_effect=range(1, 7))}, ): self.assertDictEqual( salt.states.loop.until_no_eval( @@ -334,9 +330,7 @@ class LoopTestCaseNoEval(TestCase, LoaderModuleMockMixin): """ with patch.dict( salt.states.loop.__salt__, # pylint: disable=no-member - { - "foo.bar": MagicMock(side_effect=range(1, 7)) - }, # pylint: disable=incompatible-py3-code + {"foo.bar": MagicMock(side_effect=range(1, 7))}, ): self.assertDictEqual( salt.states.loop.until( @@ -354,9 +348,7 @@ class LoopTestCaseNoEval(TestCase, LoaderModuleMockMixin): # returning a lower number of attempts (because it's slower). with patch.dict( salt.states.loop.__salt__, # pylint: disable=no-member - { - "foo.bar": MagicMock(side_effect=range(1, 7)) - }, # pylint: disable=incompatible-py3-code + {"foo.bar": MagicMock(side_effect=range(1, 7))}, ): self.assertDictEqual( salt.states.loop.until_no_eval( diff --git a/tests/unit/test_zypp_plugins.py b/tests/unit/test_zypp_plugins.py index d7bc58e5a2e..5771c4a2d61 100644 --- a/tests/unit/test_zypp_plugins.py +++ b/tests/unit/test_zypp_plugins.py @@ -2,7 +2,7 @@ :codeauthor: Bo Maryniuk """ -import imp +import imp # pylint: disable=deprecated-module import os import pytest diff --git a/tests/unit/utils/test_configparser.py b/tests/unit/utils/test_configparser.py index ab32ec992d9..d4d3a79ed3c 100644 --- a/tests/unit/utils/test_configparser.py +++ b/tests/unit/utils/test_configparser.py @@ -179,9 +179,7 @@ class TestGitConfigParser(TestCase): self.conf.write(fp_) # Confirm that the new file was written correctly expected = self.fix_indent(ORIG_CONFIG) - # pylint: disable=string-substitution-usage-error - expected.insert(6, "\tfetch = %s" % new_refspec) - # pylint: enable=string-substitution-usage-error + expected.insert(6, f"\tfetch = {new_refspec}") self.assertEqual(self.get_lines(self.new_config), expected) def test_remove_option(self): diff --git a/tests/unit/utils/test_dns.py b/tests/unit/utils/test_dns.py index c8e72ade46f..c122ef95ca8 100644 --- a/tests/unit/utils/test_dns.py +++ b/tests/unit/utils/test_dns.py @@ -259,8 +259,8 @@ class DNSlookupsCase(TestCase): :param secure: delta cmd.run_all output for secured RESULTS """ # wrong - for wrong in wrong: - with self._mock_cmd_ret(wrong): + for _wrong in wrong: + with self._mock_cmd_ret(_wrong): self.assertEqual(lookup_cb("mockq", "A"), False) # empty response diff --git a/tests/unit/utils/test_msgpack.py b/tests/unit/utils/test_msgpack.py index 2d81c922f1b..90ad80d235f 100644 --- a/tests/unit/utils/test_msgpack.py +++ b/tests/unit/utils/test_msgpack.py @@ -15,14 +15,7 @@ import salt.utils.msgpack from salt.utils.odict import OrderedDict from tests.support.unit import TestCase -try: - import msgpack -except ImportError: - import msgpack_pure as msgpack # pylint: disable=import-error - - -# A keyword to pass to tests that use `raw`, which was added in msgpack 0.5.2 -raw = {"raw": False} if msgpack.version > (0, 5, 2) else {} +msgpack = pytest.importorskip("msgpack") @pytest.mark.skipif( @@ -157,10 +150,7 @@ class TestMsgpack(TestCase): bio.write(packer.pack(i * 2)) # value bio.seek(0) - if salt.utils.msgpack.version > (0, 6, 0): - unpacker = salt.utils.msgpack.Unpacker(bio, strict_map_key=False) - else: - unpacker = salt.utils.msgpack.Unpacker(bio) + unpacker = salt.utils.msgpack.Unpacker(bio, strict_map_key=False) for size in sizes: self.assertEqual(unpacker.unpack(), {i: i * 2 for i in range(size)}) @@ -294,7 +284,7 @@ class TestMsgpack(TestCase): class MyUnpacker(salt.utils.msgpack.Unpacker): def __init__(self): my_kwargs = {} - super().__init__(ext_hook=self._hook, **raw) + super().__init__(ext_hook=self._hook, raw=False) def _hook(self, code, data): if code == 1: @@ -315,21 +305,20 @@ class TestMsgpack(TestCase): def _check( self, data, pack_func, unpack_func, use_list=False, strict_map_key=False ): - my_kwargs = {} - if salt.utils.msgpack.version >= (0, 6, 0): - my_kwargs["strict_map_key"] = strict_map_key - ret = unpack_func(pack_func(data), use_list=use_list, **my_kwargs) + ret = unpack_func( + pack_func(data), use_list=use_list, strict_map_key=strict_map_key + ) self.assertEqual(ret, data) def _test_pack_unicode(self, pack_func, unpack_func): test_data = ["", "abcd", ["defgh"], "Русский текст"] for td in test_data: - ret = unpack_func(pack_func(td), use_list=True, **raw) + ret = unpack_func(pack_func(td), use_list=True, raw=False) self.assertEqual(ret, td) packer = salt.utils.msgpack.Packer() data = packer.pack(td) ret = salt.utils.msgpack.Unpacker( - BytesIO(data), use_list=True, **raw + BytesIO(data), use_list=True, raw=False ).unpack() self.assertEqual(ret, td) @@ -353,19 +342,23 @@ class TestMsgpack(TestCase): def _test_ignore_unicode_errors(self, pack_func, unpack_func): ret = unpack_func( - pack_func(b"abc\xeddef", use_bin_type=False), unicode_errors="ignore", **raw + pack_func(b"abc\xeddef", use_bin_type=False), + unicode_errors="ignore", + raw=False, ) self.assertEqual("abcdef", ret) def _test_strict_unicode_unpack(self, pack_func, unpack_func): packed = pack_func(b"abc\xeddef", use_bin_type=False) - self.assertRaises(UnicodeDecodeError, unpack_func, packed, use_list=True, **raw) + self.assertRaises( + UnicodeDecodeError, unpack_func, packed, use_list=True, raw=False + ) def _test_ignore_errors_pack(self, pack_func, unpack_func): ret = unpack_func( pack_func("abc\uDC80\uDCFFdef", use_bin_type=True, unicode_errors="ignore"), use_list=True, - **raw + raw=False, ) self.assertEqual("abcdef", ret) @@ -373,10 +366,6 @@ class TestMsgpack(TestCase): ret = unpack_func(pack_func(b"abc"), use_list=True) self.assertEqual(b"abc", ret) - @pytest.mark.skipif( - salt.utils.msgpack.version < (0, 2, 2), - "use_single_float was added in msgpack==0.2.2", - ) def _test_pack_float(self, pack_func, **kwargs): self.assertEqual( b"\xca" + struct.pack(">f", 1.0), pack_func(1.0, use_single_float=True) @@ -403,16 +392,9 @@ class TestMsgpack(TestCase): pairlist = [(b"a", 1), (2, b"b"), (b"foo", b"bar")] packer = salt.utils.msgpack.Packer() packed = packer.pack_map_pairs(pairlist) - if salt.utils.msgpack.version > (0, 6, 0): - unpacked = unpack_func(packed, object_pairs_hook=list, strict_map_key=False) - else: - unpacked = unpack_func(packed, object_pairs_hook=list) + unpacked = unpack_func(packed, object_pairs_hook=list, strict_map_key=False) self.assertEqual(pairlist, unpacked) - @pytest.mark.skipif( - salt.utils.msgpack.version < (0, 6, 0), - "getbuffer() was added to Packer in msgpack 0.6.0", - ) def _test_get_buffer(self, pack_func, **kwargs): packer = msgpack.Packer(autoreset=False, use_bin_type=True) packer.pack([1, 2]) diff --git a/tests/unit/utils/test_systemd.py b/tests/unit/utils/test_systemd.py index 8f7e1de3b7a..20e1aaeda0c 100644 --- a/tests/unit/utils/test_systemd.py +++ b/tests/unit/utils/test_systemd.py @@ -351,8 +351,6 @@ class SystemdTestCase(TestCase): Raised by DBUS, e.g. when a PID does not belong to a service """ - ... - dbus_mock = Mock() dbus_mock.DBusException = DBusException() dbus_mock.GetUnitByPID = Mock(site_effect=dbus_mock.DBusException) diff --git a/tests/unit/utils/test_thin.py b/tests/unit/utils/test_thin.py index d67dca16890..b9c7781af6d 100644 --- a/tests/unit/utils/test_thin.py +++ b/tests/unit/utils/test_thin.py @@ -113,7 +113,8 @@ class SSHThinTestCase(TestCase): return popen - def _version_info(self, major=None, minor=None): + @staticmethod + def _version_info(major=None, minor=None): """ Fake version info. @@ -801,7 +802,7 @@ class SSHThinTestCase(TestCase): "salt.utils.thin.tempfile.mkstemp", MagicMock(return_value=(3, ".temporary")) ) @patch("salt.utils.thin.shutil", MagicMock()) - @patch("salt.utils.thin.sys.version_info", _version_info(None, 3, 6)) + @patch("salt.utils.thin.sys.version_info", _version_info(3, 6)) @patch("salt.utils.path.which", MagicMock(return_value="/usr/bin/python")) def test_gen_thin_compression_fallback_py3(self): """ @@ -852,7 +853,7 @@ class SSHThinTestCase(TestCase): "salt.utils.thin.tempfile.mkstemp", MagicMock(return_value=(3, ".temporary")) ) @patch("salt.utils.thin.shutil", MagicMock()) - @patch("salt.utils.thin.sys.version_info", _version_info(None, 3, 6)) + @patch("salt.utils.thin.sys.version_info", _version_info(3, 6)) @patch("salt.utils.path.which", MagicMock(return_value="/usr/bin/python")) def test_gen_thin_control_files_written_py3(self): """ @@ -905,7 +906,7 @@ class SSHThinTestCase(TestCase): "salt.utils.thin.tempfile.mkstemp", MagicMock(return_value=(3, ".temporary")) ) @patch("salt.utils.thin.shutil", MagicMock()) - @patch("salt.utils.thin.sys.version_info", _version_info(None, 3, 6)) + @patch("salt.utils.thin.sys.version_info", _version_info(3, 6)) @patch("salt.utils.hashutils.DigestCollector", MagicMock()) @patch("salt.utils.path.which", MagicMock(return_value="/usr/bin/python")) def test_gen_thin_main_content_files_written_py3(self): @@ -974,7 +975,7 @@ class SSHThinTestCase(TestCase): "salt.utils.thin.tempfile.mkstemp", MagicMock(return_value=(3, ".temporary")) ) @patch("salt.utils.thin.shutil", MagicMock()) - @patch("salt.utils.thin.sys.version_info", _version_info(None, 3, 6)) + @patch("salt.utils.thin.sys.version_info", _version_info(3, 6)) @patch("salt.utils.hashutils.DigestCollector", MagicMock()) @patch("salt.utils.path.which", MagicMock(return_value="/usr/bin/python")) def test_gen_thin_ext_alternative_content_files_written_py3(self): @@ -1087,7 +1088,7 @@ class SSHThinTestCase(TestCase): "salt.utils.thin.tempfile.mkstemp", MagicMock(return_value=(3, ".temporary")) ) @patch("salt.utils.thin.shutil", MagicMock()) - @patch("salt.utils.thin.sys.version_info", _version_info(None, 3, 6)) + @patch("salt.utils.thin.sys.version_info", _version_info(3, 6)) def test_gen_thin_control_files_written_access_denied_cwd(self): """ Test thin.gen_thin function if control files are written (version, salt-call etc) diff --git a/tests/wheeltest.py b/tests/wheeltest.py index 93880b0b9f3..1f661941a81 100644 --- a/tests/wheeltest.py +++ b/tests/wheeltest.py @@ -3,9 +3,7 @@ Test interacting with the wheel system. This script is useful when testing wheel modules """ - - -import optparse +import optparse # pylint: disable=deprecated-module import pprint import salt.auth diff --git a/tools/__init__.py b/tools/__init__.py index 1d46e63b2d5..f5131d0e7f9 100644 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -3,8 +3,7 @@ import pathlib import sys import ptscripts -from ptscripts.parser import DefaultRequirementsConfig -from ptscripts.virtualenv import VirtualEnvConfig +from ptscripts.models import DefaultPipConfig, VirtualEnvPipConfig REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent REQUIREMENTS_FILES_PATH = REPO_ROOT / "requirements" @@ -12,16 +11,16 @@ STATIC_REQUIREMENTS_PATH = REQUIREMENTS_FILES_PATH / "static" CI_REQUIREMENTS_FILES_PATH = ( STATIC_REQUIREMENTS_PATH / "ci" / "py{}.{}".format(*sys.version_info) ) -DEFAULT_REQS_CONFIG = DefaultRequirementsConfig( - pip_args=[ +DEFAULT_REQS_CONFIG = DefaultPipConfig( + install_args=[ f"--constraint={REQUIREMENTS_FILES_PATH / 'constraints.txt'}", ], requirements_files=[ CI_REQUIREMENTS_FILES_PATH / "tools.txt", ], ) -RELEASE_VENV_CONFIG = VirtualEnvConfig( - pip_args=[ +RELEASE_VENV_CONFIG = VirtualEnvPipConfig( + install_args=[ f"--constraint={REQUIREMENTS_FILES_PATH / 'constraints.txt'}", ], requirements_files=[ @@ -29,7 +28,7 @@ RELEASE_VENV_CONFIG = VirtualEnvConfig( ], add_as_extra_site_packages=True, ) -ptscripts.set_default_requirements_config(DEFAULT_REQS_CONFIG) +ptscripts.set_default_config(DEFAULT_REQS_CONFIG) ptscripts.register_tools_module("tools.changelog") ptscripts.register_tools_module("tools.ci") ptscripts.register_tools_module("tools.docs") diff --git a/tools/changelog.py b/tools/changelog.py index f39b3ed0a43..ab6a4e79de6 100644 --- a/tools/changelog.py +++ b/tools/changelog.py @@ -14,6 +14,7 @@ import textwrap from jinja2 import Environment, FileSystemLoader from ptscripts import Context, command_group +from ptscripts.models import VirtualEnvPipConfig from tools.utils import REPO_ROOT, Version @@ -24,16 +25,16 @@ changelog = command_group( name="changelog", help="Changelog tools", description=__doc__, - venv_config={ - "requirements_files": [ + venv_config=VirtualEnvPipConfig( + requirements_files=[ REPO_ROOT / "requirements" / "static" / "ci" / "py{}.{}".format(*sys.version_info) - / "changelog.txt" + / "changelog.txt", ], - }, + ), ) @@ -110,18 +111,18 @@ def update_rpm(ctx: Context, salt_version: Version, draft: bool = False): header = f"* {date} Salt Project Packaging - {str_salt_version}\n" parts = orig.split("%changelog") tmpspec = "pkg/rpm/salt.spec.1" - with open(tmpspec, "w") as wfp: + with open(tmpspec, "w", encoding="utf-8") as wfp: wfp.write(parts[0]) wfp.write("%changelog\n") wfp.write(header) wfp.write(changes) wfp.write(parts[1]) try: - with open(tmpspec) as rfp: + with open(tmpspec, encoding="utf-8") as rfp: if draft: ctx.info(rfp.read()) else: - with open("pkg/rpm/salt.spec", "w") as wfp: + with open("pkg/rpm/salt.spec", "w", encoding="utf-8") as wfp: wfp.write(rfp.read()) finally: os.remove(tmpspec) @@ -153,20 +154,20 @@ def update_deb(ctx: Context, salt_version: Version, draft: bool = False): tmpchanges = "pkg/rpm/salt.spec.1" debian_changelog_path = "pkg/debian/changelog" tmp_debian_changelog_path = f"{debian_changelog_path}.1" - with open(tmp_debian_changelog_path, "w") as wfp: + with open(tmp_debian_changelog_path, "w", encoding="utf-8") as wfp: wfp.write(f"salt ({salt_version}) stable; urgency=medium\n\n") wfp.write(formated) wfp.write( f"\n -- Salt Project Packaging {date}\n\n" ) - with open(debian_changelog_path) as rfp: + with open(debian_changelog_path, encoding="utf-8") as rfp: wfp.write(rfp.read()) try: - with open(tmp_debian_changelog_path) as rfp: + with open(tmp_debian_changelog_path, encoding="utf-8") as rfp: if draft: ctx.info(rfp.read()) else: - with open(debian_changelog_path, "w") as wfp: + with open(debian_changelog_path, "w", encoding="utf-8") as wfp: wfp.write(rfp.read()) finally: os.remove(tmp_debian_changelog_path) @@ -254,7 +255,7 @@ def update_release_notes( return unreleased = " - UNRELEASED" - warning = f""" + warning = """