Skip to content

Check for Unsupported Files and Display Errors and Warnings#1509

Merged
charliermarsh merged 5 commits intoastral-sh:mainfrom
saadmk11:check-unsupported-files
Dec 31, 2022
Merged

Check for Unsupported Files and Display Errors and Warnings#1509
charliermarsh merged 5 commits intoastral-sh:mainfrom
saadmk11:check-unsupported-files

Conversation

@saadmk11
Copy link
Contributor

closes #1473

Reference:

  • (Optional) If we don't find any files, show a warning.
  • If we're passed a non .py or .pyi file, raise an error for that file (but process any valid files).

Originally posted by @charliermarsh in #1473 (comment)

@charliermarsh
Copy link
Member

Thank you! I decided to make the "unsupported file type" thing a hard error. I may regret it, we'll see!

@charliermarsh charliermarsh merged commit 815284f into astral-sh:main Dec 31, 2022
@saadmk11 saadmk11 deleted the check-unsupported-files branch December 31, 2022 13:14
renovate bot referenced this pull request in ixm-one/pytest-cmake-presets Dec 31, 2022
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [ruff](https://togithub.com/charliermarsh/ruff) | `^0.0.203` ->
`^0.0.204` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.204/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.204/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.204/compatibility-slim/0.0.203)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.204/confidence-slim/0.0.203)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.204`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.204)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.203...v0.0.204)

#### What's Changed

- Trim CLI help during generation by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1492](https://togithub.com/charliermarsh/ruff/pull/1492)
- Escape strings when formatting check messages by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1493](https://togithub.com/charliermarsh/ruff/pull/1493)
- Add a "fix message" to every autofix-able check by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1489](https://togithub.com/charliermarsh/ruff/pull/1489)
- Stop overriding locations for expressions within f-strings by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/charliermarsh/ruff/pull/1494](https://togithub.com/charliermarsh/ruff/pull/1494)
- Remove F831 by [@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/charliermarsh/ruff/pull/1495](https://togithub.com/charliermarsh/ruff/pull/1495)
- Fix detection of changed imports in isort plugin by
[@&#8203;squiddy](https://togithub.com/squiddy) in
[https://github.com/charliermarsh/ruff/pull/1504](https://togithub.com/charliermarsh/ruff/pull/1504)
- Remove unused snapshots by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/charliermarsh/ruff/pull/1497](https://togithub.com/charliermarsh/ruff/pull/1497)
- Improve `T20X` ranges by [@&#8203;harupy](https://togithub.com/harupy)
in
[https://github.com/charliermarsh/ruff/pull/1502](https://togithub.com/charliermarsh/ruff/pull/1502)
- Improve F811 range for function and class definitions by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/charliermarsh/ruff/pull/1499](https://togithub.com/charliermarsh/ruff/pull/1499)
- Improve PLW0120 range by [@&#8203;harupy](https://togithub.com/harupy)
in
[https://github.com/charliermarsh/ruff/pull/1500](https://togithub.com/charliermarsh/ruff/pull/1500)
- Fix N818 range by [@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/charliermarsh/ruff/pull/1503](https://togithub.com/charliermarsh/ruff/pull/1503)
- Include fix commit message when showing violations together with
source by [@&#8203;squiddy](https://togithub.com/squiddy) in
[https://github.com/charliermarsh/ruff/pull/1505](https://togithub.com/charliermarsh/ruff/pull/1505)
- Fix E722 and F707 ranges by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/charliermarsh/ruff/pull/1508](https://togithub.com/charliermarsh/ruff/pull/1508)
- Adjust `test_path` helper to detect round-trip autofix issues by
[@&#8203;squiddy](https://togithub.com/squiddy) in
[https://github.com/charliermarsh/ruff/pull/1501](https://togithub.com/charliermarsh/ruff/pull/1501)
- Generate source code with detected line ending by
[@&#8203;squiddy](https://togithub.com/squiddy) in
[https://github.com/charliermarsh/ruff/pull/1487](https://togithub.com/charliermarsh/ruff/pull/1487)
- Check for Unsupported Files and Display Errors and Warnings by
[@&#8203;saadmk11](https://togithub.com/saadmk11) in
[https://github.com/charliermarsh/ruff/pull/1509](https://togithub.com/charliermarsh/ruff/pull/1509)

**Full Changelog**:
astral-sh/ruff@v0.0.203...v0.0.204

</details>

---

### Configuration

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

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, 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 [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC43NC4yIiwidXBkYXRlZEluVmVyIjoiMzQuNzQuMiJ9-->

Signed-off-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@andersk
Copy link
Contributor

andersk commented Jan 1, 2023

Zulip has many Python scripts that are marked executable with a shebang line but without a .py extension. I think this should be reverted.

@charliermarsh
Copy link
Member

Do you want / expect those to be linted? If so, how have you linted them in the past, given that we only check .py and .pyi files?

@charliermarsh
Copy link
Member

We can change this to just attempt to lint them, which would raise a syntax error for any non-Python files that are passed directly.

@andersk
Copy link
Contributor

andersk commented Jan 1, 2023

We linted all files passed directly on the command line, regardless of extension, until pretty recently (I’m checking where this changed).

@charliermarsh
Copy link
Member

Okay, I'm happy to revert to that behavior.

@charliermarsh
Copy link
Member

(I guess my question was: are you passing those directly on the command line?)

@andersk
Copy link
Contributor

andersk commented Jan 1, 2023

Yes, Zulip has a wrapper script that finds all the Python files in the Git repository via extensions and shebang lines, and passes them directly on the command line.

@charliermarsh
Copy link
Member

Ok, I can fix this later tonight. Or feel free to send a PR of course. Sorry for the trouble.

@andersk
Copy link
Contributor

andersk commented Jan 1, 2023

git bisect shows this changed in #1241.

(The problem isn’t urgent for Zulip, since Zulip uses a pinned version of Ruff.)

@charliermarsh
Copy link
Member

Tracking here: #1541

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Print warning when run against an unsupported file

3 participants