Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture python warnings and report some of them as matches #3324

Merged
merged 1 commit into from
May 9, 2023
Merged

Conversation

ssbarnea
Copy link
Member

@ssbarnea ssbarnea commented Apr 22, 2023

This change introduces a new way to generate warnings in linter, one that uses the warnings support in Python. The benefit is that this allows use to generate warnings from anywhere inside the code without having to pass them from function to function.

For start we will be using this for internal rules, like ability to report outdated tag names in noqa comments.

@github-actions github-actions bot added the bug label Apr 22, 2023
@ssbarnea ssbarnea requested a review from cidrblock April 22, 2023 12:28
@ssbarnea ssbarnea changed the title Capture python warnings and report them as matches Capture python warnings and report some of them as matches Apr 23, 2023
@ssbarnea ssbarnea force-pushed the fix/clean branch 2 times, most recently from 89d9e72 to 1aeb6f4 Compare May 8, 2023 10:16
This change introduces a new way to generate warnings in linter, one
that uses the warnings support in Python. The benefit is that this
allows use to generate warnings from anywhere inside the code without
having to pass them from function to function.

For start we will be using this for internal rules, like ability to
report outdated noqa comments.
@ssbarnea ssbarnea added enhancement and removed bug labels May 8, 2023
@github-actions github-actions bot added the bug label May 8, 2023
@ssbarnea ssbarnea marked this pull request as ready for review May 8, 2023 10:19
@ssbarnea ssbarnea requested a review from a team as a code owner May 8, 2023 10:19
@ssbarnea ssbarnea requested review from a team, audgirka, priyamsahoo and shatakshiiii May 8, 2023 10:19
@ssbarnea ssbarnea merged commit 62e3e21 into main May 9, 2023
18 of 19 checks passed
@ssbarnea ssbarnea deleted the fix/clean branch May 9, 2023 07:58
nrdufour added a commit to nrdufour/home-ops that referenced this pull request Jul 27, 2023
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ansible-lint](https://github.com/ansible/ansible-lint) ([changelog](https://github.com/ansible/ansible-lint/releases)) | minor | `==6.15.0` -> `==6.17.2` |

---

### Release Notes

<details>
<summary>ansible/ansible-lint (ansible-lint)</summary>

### [`v6.17.2`](https://github.com/ansible/ansible-lint/releases/tag/v6.17.2)

[Compare Source](ansible/ansible-lint@v6.17.1...v6.17.2)

#### Bugfixes

-   Allow use as a reusable github action ([#&#8203;3513](ansible/ansible-lint#3513)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Add action and args properties to task class ([#&#8203;3576](ansible/ansible-lint#3576)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Fixed error when sarif file option is provided ([#&#8203;3587](ansible/ansible-lint#3587)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Add NetBSD as a recognized platform ([#&#8203;3586](ansible/ansible-lint#3586)) [@&#8203;he32](https://github.com/he32)
-   Display ansible-compat version alongwith with other deps ([#&#8203;3584](ansible/ansible-lint#3584)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Refactored syntax-checking ([#&#8203;3568](ansible/ansible-lint#3568)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Avoid app reinitialization during syntax-check ([#&#8203;3563](ansible/ansible-lint#3563)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Allow config file to have `.yaml` extension ([#&#8203;3559](ansible/ansible-lint#3559)) [@&#8203;bdsoha](https://github.com/bdsoha)
-   Allow lists of lists of strings for vars_files ([#&#8203;3561](ansible/ansible-lint#3561)) [@&#8203;ajinkyau](https://github.com/ajinkyau)

### [`v6.17.1`](https://github.com/ansible/ansible-lint/releases/tag/v6.17.1)

[Compare Source](ansible/ansible-lint@v6.17.0...v6.17.1)

#### Bugfixes

-   Update guess install method check ([#&#8203;3553](ansible/ansible-lint#3553)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Fix exclude logic bug that can cause cause partial linting ([#&#8203;3552](ansible/ansible-lint#3552)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Make profile information on summary line more clear ([#&#8203;3545](ansible/ansible-lint#3545)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Avoid adding pip related messages if installation method is different ([#&#8203;3551](ansible/ansible-lint#3551)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Avoid false positive with var-naming\[no-role-prefix] ([#&#8203;3550](ansible/ansible-lint#3550)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Make refresh_schemas handle firewalls that cut the file transfer midway ([#&#8203;3546](ansible/ansible-lint#3546)) [@&#8203;sverrehu](https://github.com/sverrehu)
-   Rename marketplace action ([#&#8203;3548](ansible/ansible-lint#3548)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Fix action name ([#&#8203;3536](ansible/ansible-lint#3536)) [@&#8203;coaxial](https://github.com/coaxial)
-   Handling of exclude paths with trailing slashs ([#&#8203;3527](ansible/ansible-lint#3527)) [@&#8203;hille721](https://github.com/hille721)
-   Ensure that rules collections use Runtime in offline mode ([#&#8203;3526](ansible/ansible-lint#3526)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Avoid using get_app() from inside the rule ([#&#8203;3525](ansible/ansible-lint#3525)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Avoid dependency error from rich ([#&#8203;3517](ansible/ansible-lint#3517)) [@&#8203;ssbarnea](https://github.com/ssbarnea)

### [`v6.17.0`](https://github.com/ansible/ansible-lint/releases/tag/v6.17.0)

[Compare Source](ansible/ansible-lint@v6.16.2...v6.17.0)

#### Minor Changes

-   fqcn\[deep]: detect deep plugins ([#&#8203;3502](ansible/ansible-lint#3502)) [@&#8203;ssbarnea](https://github.com/ssbarnea)

#### Bugfixes

-   Reimplement file exclusion logic ([#&#8203;3507](ansible/ansible-lint#3507)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Check validity of 'become_method' values from code ([#&#8203;3499](ansible/ansible-lint#3499)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Fix role_name\_ prefix include_role var name error ([#&#8203;3500](ansible/ansible-lint#3500)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Hide pip error if not present ([#&#8203;3494](ansible/ansible-lint#3494)) [@&#8203;Et7f3](https://github.com/Et7f3)
-   Update formatter to avoid reporting paths with .. ([#&#8203;3496](ansible/ansible-lint#3496)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Remove false positive on 'cacheable' property of set_fact ([#&#8203;3490](ansible/ansible-lint#3490)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Add missing become_method plugins to the schema ([#&#8203;3484](ansible/ansible-lint#3484)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Add support for ansible-builder v3 schema ([#&#8203;3480](ansible/ansible-lint#3480)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Add Github Marketplace Action ([#&#8203;3476](ansible/ansible-lint#3476)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Add oracle linux 8.8 ([#&#8203;3479](ansible/ansible-lint#3479)) [@&#8203;facorazza](https://github.com/facorazza)
-   Revert ansible-compat vendoring ([#&#8203;3478](ansible/ansible-lint#3478)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Updated file or dir not found message ([#&#8203;3474](ansible/ansible-lint#3474)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Check for included role prefix instead of current one ([#&#8203;3473](ansible/ansible-lint#3473)) [@&#8203;ssbarnea](https://github.com/ssbarnea)

### [`v6.16.2`](https://github.com/ansible/ansible-lint/releases/tag/v6.16.2)

[Compare Source](ansible/ansible-lint@v6.16.1...v6.16.2)

#### Bugfixes

-   Update test dependencies ([#&#8203;3470](ansible/ansible-lint#3470)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Fix and document installing of requirements.yml files ([#&#8203;3471](ansible/ansible-lint#3471)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Do not ever exclude files given as arguments ([#&#8203;3468](ansible/ansible-lint#3468)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Ensure we return error if argument gives are not present ([#&#8203;3467](ansible/ansible-lint#3467)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Allow rules to expose all tags they can produce ([#&#8203;3464](ansible/ansible-lint#3464)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Enable var-name rule to detect read-only variables ([#&#8203;3462](ansible/ansible-lint#3462)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Add Oracle Enterprise Linux 7.\* ([#&#8203;3463](ansible/ansible-lint#3463)) [@&#8203;Rylon](https://github.com/Rylon)
-   Fix for var-naming rule to not break on include_tasks and vars ([#&#8203;3458](ansible/ansible-lint#3458)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   var-naming now prevents use of Ansible reserved names ([#&#8203;3460](ansible/ansible-lint#3460)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Ensure that we also lint files from git submodules ([#&#8203;3431](ansible/ansible-lint#3431)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Adding 2.16 to the list of allowed ansible-core versions in meta-runtime rule ([#&#8203;3455](ansible/ansible-lint#3455)) [@&#8203;alisonlhart](https://github.com/alisonlhart)

### [`v6.16.1`](https://github.com/ansible/ansible-lint/releases/tag/v6.16.1)

[Compare Source](ansible/ansible-lint@v6.16.0...v6.16.1)

#### Bugfixes

-   Update lock file to use ansible-core 2.15.0 ([#&#8203;3449](ansible/ansible-lint#3449)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Install requirements from galaxy.yml and tests/requirements.yml ([#&#8203;3446](ansible/ansible-lint#3446)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Add Kali Linux as a supported platform ([#&#8203;3448](ansible/ansible-lint#3448)) [@&#8203;mcdonnnj](https://github.com/mcdonnnj)
-   Do not trigger no_handler upon complex conditions ([#&#8203;3437](ansible/ansible-lint#3437)) [@&#8203;klaus-tux](https://github.com/klaus-tux)
-   Hide warning about unique filter originating from core ([#&#8203;3436](ansible/ansible-lint#3436)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Relax ruamel-yaml requirements ([#&#8203;3433](ansible/ansible-lint#3433)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Suggest correct alternative for `with_filetree` ([#&#8203;3432](ansible/ansible-lint#3432)) [@&#8203;ErwinJanssen](https://github.com/ErwinJanssen)
-   Upgrade var-naming rule to include role name prefix ([#&#8203;3422](ansible/ansible-lint#3422)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Fix exception when using reformatting on scalars ([#&#8203;3423](ansible/ansible-lint#3423)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Find and lint imported playbooks ([#&#8203;3413](ansible/ansible-lint#3413)) [@&#8203;ajinkyau](https://github.com/ajinkyau)

### [`v6.16.0`](https://github.com/ansible/ansible-lint/releases/tag/v6.16.0)

[Compare Source](ansible/ansible-lint@v6.15.0...v6.16.0)

#### Minor Changes

-   Capture python warnings and report some of them as matches ([#&#8203;3324](ansible/ansible-lint#3324)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Capture and hide ansible core warnings by default ([#&#8203;3361](ansible/ansible-lint#3361)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Remove progressive mode ([#&#8203;3350](ansible/ansible-lint#3350)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Enforce use of lineno variable name inside the library ([#&#8203;3326](ansible/ansible-lint#3326)) [@&#8203;ssbarnea](https://github.com/ssbarnea)

#### Bugfixes

-   Add Amazon Linux 2023 as a supported platform ([#&#8203;3405](ansible/ansible-lint#3405)) [@&#8203;artis3n](https://github.com/artis3n)
-   Capture python warnings and report some of them as matches ([#&#8203;3324](ansible/ansible-lint#3324)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Fix missing required arguments issue from args rule ([#&#8203;3402](ansible/ansible-lint#3402)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Change matchtask to receive a Task instance ([#&#8203;3403](ansible/ansible-lint#3403)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Require ruamel.yaml>=0.17.24 ([#&#8203;3406](ansible/ansible-lint#3406)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Avoid exception when trying to load invalid text files ([#&#8203;3399](ansible/ansible-lint#3399)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Fix ansible collection path detection ([#&#8203;3398](ansible/ansible-lint#3398)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   ruff: Address FBT002 ([#&#8203;3389](ansible/ansible-lint#3389)) [@&#8203;shatakshiiii](https://github.com/shatakshiiii)
-   More pathlib adoption ([#&#8203;3390](ansible/ansible-lint#3390)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Avoid dropping comments on YAML transformation ([#&#8203;3392](ansible/ansible-lint#3392)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Correct docs on navigator schema location ([#&#8203;3394](ansible/ansible-lint#3394)) [@&#8203;yajo](https://github.com/yajo)
-   Fix changelog schema for connection plugins ([#&#8203;3388](ansible/ansible-lint#3388)) [@&#8203;Qalthos](https://github.com/Qalthos)
-   Migrate from os.path to pathlib ([#&#8203;3384](ansible/ansible-lint#3384)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Remove resolvelib from requirements lock ([#&#8203;3387](ansible/ansible-lint#3387)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Make cwd use pathlib ([#&#8203;3383](ansible/ansible-lint#3383)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   ruff: Address PGH ([#&#8203;3380](ansible/ansible-lint#3380)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   ruff: Address A ([#&#8203;3379](ansible/ansible-lint#3379)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   ruff: Address B ([#&#8203;3377](ansible/ansible-lint#3377)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   ruff: Address SLF ([#&#8203;3372](ansible/ansible-lint#3372)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   ruff: Address `SIM` ([#&#8203;3373](ansible/ansible-lint#3373)) [@&#8203;shatakshiiii](https://github.com/shatakshiiii)
-   ruff: Address EXE ([#&#8203;3367](ansible/ansible-lint#3367)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   ruff: Address BLE ([#&#8203;3368](ansible/ansible-lint#3368)) [@&#8203;shatakshiiii](https://github.com/shatakshiiii)
-   ruff: Address INP and PLW ([#&#8203;3366](ansible/ansible-lint#3366)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Add initial handling of submodules to contribution docs ([#&#8203;3362](ansible/ansible-lint#3362)) [@&#8203;klaus-tux](https://github.com/klaus-tux)
-   ruff: Address T and RET ([#&#8203;3364](ansible/ansible-lint#3364)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Find "changed" not only in first "when" condition ([#&#8203;3358](ansible/ansible-lint#3358)) [@&#8203;klaus-tux](https://github.com/klaus-tux)
-   ruff: fix S rule ([#&#8203;3363](ansible/ansible-lint#3363)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Make MatchError a dataclass ([#&#8203;3345](ansible/ansible-lint#3345)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Remove `EM` from ruff ignores ([#&#8203;3356](ansible/ansible-lint#3356)) [@&#8203;shatakshiiii](https://github.com/shatakshiiii)
-   Mock jinja filters to prevent templating errors ([#&#8203;3355](ansible/ansible-lint#3355)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Update schema files ([#&#8203;3354](ansible/ansible-lint#3354)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Add Fedora 38 to meta.json schema file ([#&#8203;3353](ansible/ansible-lint#3353)) [@&#8203;Marek-Mantaj-Mobica](https://github.com/Marek-Mantaj-Mobica)
-   Remove `RUF` from ruff ignores ([#&#8203;3346](ansible/ansible-lint#3346)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Remove `G` from ruff ignores ([#&#8203;3332](ansible/ansible-lint#3332)) [@&#8203;shatakshiiii](https://github.com/shatakshiiii)
-   Remove `ISC` from ruff ignores ([#&#8203;3342](ansible/ansible-lint#3342)) [@&#8203;shatakshiiii](https://github.com/shatakshiiii)
-   Remove `C` from ruff ignores ([#&#8203;3343](ansible/ansible-lint#3343)) [@&#8203;ajinkyau](https://github.com/ajinkyau)
-   Make linter configuration a dataclass ([#&#8203;3334](ansible/ansible-lint#3334)) [@&#8203;ssbarnea](https://github.com/ssbarnea)
-   Remove `N` from ruff ignores ([#&#8203;3328](ansible/ansible-lint#3328)) [@&#8203;shatakshiiii](https://github.com/shatakshiiii)
-   Remove useless . from additional_dependencies in pre-commit hook ([#&#8203;3327](ansible/ansible-lint#3327)) [@&#8203;trallnag](https://github.com/trallnag)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4yMy4yIiwidXBkYXRlZEluVmVyIjoiMzYuMjMuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: Nicolas Dufour <nrdufour@gmail.com>
Reviewed-on: https://git.home/nrdufour/home-ops/pulls/9
Co-authored-by: Renovate <renovate@ptinem.io>
Co-committed-by: Renovate <renovate@ptinem.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants