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

Add all PEP-585 names to UP006 rule #5454

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

wookie184
Copy link
Contributor

Closes #3936

Summary

Building on #4420, adds the remaining PEP-585 names.

Test Plan

Added snapshot tests for a few cases.

@charliermarsh
Copy link
Member

Hmm, I believe these are already covered by the deprecated import rule that we have in pyupgrade. There’s clearly some overlap in responsibilities between the two.

@wookie184
Copy link
Contributor Author

Hmm, I believe these are already covered by the deprecated import rule that we have in pyupgrade. There’s clearly some overlap in responsibilities between the two.

Currently, UP035 detects imports of many deprecated names, while UP006 detects usage of just PEP 585 deprecated names. So e.g.

from typing import List  # Flagged by UP035
x: List  # Flagged by UP006

import typing
x: typing.List  # Flagged by UP006

It definitely seems like something that could be merged into one rule, or we could have two (one for pep 585 and one for other deprecated names) which share their implementation.


Also made me realise an issue with this PR currently:

import typing
from typing import Sequence

x: Sequence
x: typing.Sequence

causes an error

error: Failed to create fix for NonPEP585Annotation: Unable to insert `Sequence` into scope due to name conflict
error: Failed to create fix for NonPEP585Annotation: Unable to insert `Sequence` into scope due to name conflict
test.py:2:1: UP035 [*] Import from `collections.abc` instead: `Sequence`
test.py:4:4: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
test.py:5:4: UP006 Use `collections.abc.Sequence` instead of `typing.Sequence` for type annotation
Found 3 errors.
[*] 1 potentially fixable with the --fix option.

although weirdly when I actually run --fix it runs 2 fixes (including UP006) and does actually fix the code properly... I guess ruff reruns fixes until the output is stable?

@charliermarsh
Copy link
Member

I think this originally arose from pyupgrade, which has two separate "rules" for deprecated imports vs. PEP 585 rewrites (for builtins only). Most deprecated imports can be fixed by only modifying the import site, since they typically involve members that were moved from one module to another. Meanwhile, the PEP 585 built-in rewrites don't require changing imports at all, since they only change to list, set, etc., which are available as builtins. Later, when we added support for multi-location fixes, we added defaultdict and deque to the PEP 585 rule; and we added typing.List and friends to the deprecated import rule, even though it was already covered in a sense by the PEP 585 rule. Anyway, just explaining why this happened, not how we should deal with it.

The current setup honestly seems okay to me (the PEP 585 rule deals with members that need to be renamed; the deprecated imports rule only fixes imports), but I'd probably also be okay with removing the PEP 585 imports from "deprecated imports" and moving them into this rule. Though it might be sort of complicated to pull off given how different the implementations are, and some of the quirks around how they'd need to be gated (e.g., you can rewrite List to list if from __future__ import annotations is present, but you can't rewrite to a collections.abc import), at which point, I may question the value.

although weirdly when I actually run --fix it runs 2 fixes (including UP006) and does actually fix the code properly... I guess ruff reruns fixes until the output is stable?

Yeah, that's right -- we iteratively fix up to a certain number of iterations.

@wookie184
Copy link
Contributor Author

Thanks for explaining, I agree that it seems quite complicated to combine the rules, and removing the duplication of names would probably also require a decent amount of work. Maybe something that could be done at some point but I'm not sure it's necessary for this PR.

I fixed the issue with the name conflict when both types of import are already there (the autofix for this case still works, it just needs the UP035 autofix first).

Does this look alright?

@flying-sheep
Copy link
Contributor

Ah, this is great! It would be great to have this automated!

@zanieb
Copy link
Member

zanieb commented Oct 19, 2023

@charliermarsh I think this is probably reasonable as discussed?

@charliermarsh
Copy link
Member

I feel like this could be better suited to inclusion in UP035 -- since the deprecated imports flagged in there should be a superset of the PEP 585 changes.

@charliermarsh
Copy link
Member

charliermarsh commented Oct 21, 2023

As an example: if someone does import pipes; pipes.quote, we probably want to rewrite that to import shlex; shlex.quote. But that's unrelated to PEP 585.

@wookie184
Copy link
Contributor Author

I feel like this could be better suited to inclusion in UP035 -- since the deprecated imports flagged in there should be a superset of the PEP 585 changes.

I can't think of a case that you'd want to have a rule to detect/fix

from typing import List
x: List

but not

import typing
x: typing.List

I would expect them to be treated as equivalent by a rule attempting to update to PEP 585 annotations.

As an example: if someone does import pipes; pipes.quote, we probably want to rewrite that to import shlex; shlex.quote. But that's unrelated to PEP 585.

I think that just suggests that would make sense to implement for UP006 (ideally sharing implementation with UP035). IMO, the difference between UP006 and UP035 should just be what names are affected, not in what cases the names are changed, since that's not a helpful distinction for the user.

@charliermarsh charliermarsh self-requested a review December 1, 2023 01:56
@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Dec 1, 2023
Copy link
Contributor

github-actions bot commented Dec 1, 2023

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+5590 -0 violations, +0 -0 fixes in 41 projects)

aiven/aiven-client (+385 -0 violations, +0 -0 fixes)

+ aiven/client/argx.py:150:54: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:166:45: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:169:49: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:236:29: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:273:34: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:273:44: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:285:32: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ aiven/client/argx.py:295:29: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:298:34: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ aiven/client/argx.py:302:20: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
... 375 additional changes omitted for project

apache/airflow (+3111 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-preview --select ALL

+ airflow/__init__.py:70:8: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api/auth/backend/basic_auth.py:50:39: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api/auth/backend/kerberos_auth.py:138:53: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api/common/mark_tasks.py:178:22: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:194:14: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:215:22: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:216:6: UP006 Use `collections.abc.Iterator` instead of `Iterator` for type annotation
+ airflow/api/common/mark_tasks.py:250:15: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:272:87: UP006 Use `collections.abc.Iterator` instead of `Iterator` for type annotation
+ airflow/api/common/mark_tasks.py:51:12: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:54:6: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:85:12: UP006 Use `collections.abc.Collection` instead of `Collection` for type annotation
+ airflow/api_connexion/endpoints/dag_endpoint.py:85:11: UP006 Use `collections.abc.Collection` instead of `Collection` for type annotation
+ airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:32:24: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:32:37: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/endpoints/request_dict.py:22:32: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ airflow/api_connexion/endpoints/task_instance_endpoint.py:260:32: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api_connexion/endpoints/task_instance_endpoint.py:266:68: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api_connexion/endpoints/task_instance_endpoint.py:382:19: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ airflow/api_connexion/endpoints/update_mask.py:25:18: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ airflow/api_connexion/endpoints/update_mask.py:25:69: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ airflow/api_connexion/endpoints/update_mask.py:26:6: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ airflow/api_connexion/parameters.py:115:20: UP006 Use `collections.abc.Container` instead of `Container` for type annotation
+ airflow/api_connexion/parameters.py:89:52: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/parameters.py:89:78: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/security.py:115:59: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/security.py:136:6: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 3084 additional changes omitted for project

bokeh/bokeh (+250 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-preview --select ALL

+ release/action.py:27:31: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/action.py:27:52: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/action.py:35:47: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/build.py:144:22: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/credentials.py:37:22: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/credentials.py:40:38: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/pipeline.py:24:12: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/pipeline.py:34:31: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/ui.py:103:33: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/ui.py:24:17: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 240 additional changes omitted for project

demisto/content (+223 -0 violations, +0 -0 fixes)

+ Packs/AMP/Integrations/AMPv2/AMPv2.py:2026:33: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ Packs/AMP/Integrations/AMPv2/AMPv2.py:3358:17: UP006 Use `collections.abc.MutableMapping` instead of `MutableMapping` for type annotation
+ Packs/AMP/Integrations/AMPv2/AMPv2.py:3375:34: UP006 Use `collections.abc.MutableMapping` instead of `MutableMapping` for type annotation
+ Packs/AMP/Integrations/AMPv2/AMPv2.py:3379:35: UP006 Use `collections.abc.MutableSequence` instead of `MutableSequence` for type annotation
+ Packs/AMP/Integrations/AMPv2/AMPv2.py:3381:42: UP006 Use `collections.abc.MutableMapping` instead of `MutableMapping` for type annotation
+ Packs/AWS-Lambda/Integrations/AWS_Lambda/AWS_Lambda_test.py:432:27: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ Packs/AWS-SecurityHub/Integrations/AWSSecurityHubEventCollector/AWSSecurityHubEventCollector.py:58:71: UP006 Use `collections.abc.Iterator` instead of `Iterator` for type annotation
+ Packs/AWS_WAF/Integrations/AWSWAF/AWSWAF.py:369:44: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ Packs/Akamai_SIEM/Integrations/Akamai_SIEM/Akamai_SIEM.py:121:33: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ Packs/Arkime/Integrations/Arkime/Arkime.py:1083:29: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 213 additional changes omitted for project

ibis-project/ibis (+102 -0 violations, +0 -0 fixes)

+ ibis/backends/base/__init__.py:1005:53: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/base/__init__.py:1015:45: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/base/sql/compiler/translator.py:163:31: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/base/sqlglot/__init__.py:16:36: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/base/sqlglot/__init__.py:93:6: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/bigquery/__init__.py:725:17: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/bigquery/udf/__init__.py:203:10: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/bigquery/udf/__init__.py:325:10: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/bigquery/udf/__init__.py:40:10: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/bigquery/udf/core.py:55:18: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 92 additional changes omitted for project

pypa/build (+6 -0 violations, +0 -0 fixes)

+ src/build/__init__.py:139:37: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ src/build/__init__.py:139:84: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ src/build/__init__.py:59:28: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ src/build/__init__.py:80:45: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ src/build/__init__.py:94:47: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ src/build/__init__.py:94:69: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation

pypa/cibuildwheel (+1 -0 violations, +0 -0 fixes)

+ test/conftest.py:35:25: UP006 Use `collections.abc.Generator` instead of `Generator` for type annotation

python/mypy (+516 -0 violations, +0 -0 fixes)

+ misc/analyze_cache.py:37:29: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:37:53: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:38:25: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:38:48: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:64:29: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:74:30: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:74:53: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/perf_checker.py:15:31: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ misc/perf_checker.py:15:60: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ misc/upload-pypi.py:100:20: UP006 Use `collections.abc.Iterator` instead of `Iterator` for type annotation
... 506 additional changes omitted for project

... Truncated remaining completed projected reports due to GitHub comment length restrictions

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
UP006 4747 4747 0 0 0
FA100 843 843 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+5340 -0 violations, +0 -0 fixes in 41 projects)

aiven/aiven-client (+385 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ aiven/client/argx.py:150:54: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:166:45: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:169:49: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:236:29: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:273:34: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:273:44: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:285:32: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ aiven/client/argx.py:295:29: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ aiven/client/argx.py:298:34: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ aiven/client/argx.py:302:20: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
... 375 additional changes omitted for project

apache/airflow (+2890 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview --select ALL

+ airflow/__init__.py:70:8: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api/auth/backend/basic_auth.py:50:39: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api/auth/backend/kerberos_auth.py:138:53: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api/common/mark_tasks.py:178:22: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:194:14: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:215:22: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:216:6: UP006 Use `collections.abc.Iterator` instead of `Iterator` for type annotation
+ airflow/api/common/mark_tasks.py:250:15: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:272:87: UP006 Use `collections.abc.Iterator` instead of `Iterator` for type annotation
+ airflow/api/common/mark_tasks.py:51:12: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:54:6: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api/common/mark_tasks.py:85:12: UP006 Use `collections.abc.Collection` instead of `Collection` for type annotation
+ airflow/api_connexion/endpoints/dag_endpoint.py:85:11: UP006 Use `collections.abc.Collection` instead of `Collection` for type annotation
+ airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:32:24: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:32:37: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/endpoints/request_dict.py:22:32: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ airflow/api_connexion/endpoints/task_instance_endpoint.py:260:32: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api_connexion/endpoints/task_instance_endpoint.py:266:68: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ airflow/api_connexion/endpoints/task_instance_endpoint.py:382:19: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ airflow/api_connexion/endpoints/update_mask.py:25:18: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ airflow/api_connexion/endpoints/update_mask.py:25:69: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ airflow/api_connexion/endpoints/update_mask.py:26:6: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ airflow/api_connexion/parameters.py:115:20: UP006 Use `collections.abc.Container` instead of `Container` for type annotation
+ airflow/api_connexion/parameters.py:89:52: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/parameters.py:89:78: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/security.py:115:59: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ airflow/api_connexion/security.py:136:6: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 2863 additional changes omitted for project

bokeh/bokeh (+238 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview --select ALL

+ release/action.py:27:31: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/action.py:27:52: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/action.py:35:47: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/build.py:144:22: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/credentials.py:37:22: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/credentials.py:40:38: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/pipeline.py:24:12: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ release/pipeline.py:34:31: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/ui.py:103:33: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ release/ui.py:24:17: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 228 additional changes omitted for project

demisto/content (+223 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ Packs/AMP/Integrations/AMPv2/AMPv2.py:2026:33: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ Packs/AMP/Integrations/AMPv2/AMPv2.py:3358:17: UP006 Use `collections.abc.MutableMapping` instead of `MutableMapping` for type annotation
+ Packs/AMP/Integrations/AMPv2/AMPv2.py:3375:34: UP006 Use `collections.abc.MutableMapping` instead of `MutableMapping` for type annotation
+ Packs/AMP/Integrations/AMPv2/AMPv2.py:3379:35: UP006 Use `collections.abc.MutableSequence` instead of `MutableSequence` for type annotation
+ Packs/AMP/Integrations/AMPv2/AMPv2.py:3381:42: UP006 Use `collections.abc.MutableMapping` instead of `MutableMapping` for type annotation
+ Packs/AWS-Lambda/Integrations/AWS_Lambda/AWS_Lambda_test.py:432:27: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ Packs/AWS-SecurityHub/Integrations/AWSSecurityHubEventCollector/AWSSecurityHubEventCollector.py:58:71: UP006 Use `collections.abc.Iterator` instead of `Iterator` for type annotation
+ Packs/AWS_WAF/Integrations/AWSWAF/AWSWAF.py:369:44: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ Packs/Akamai_SIEM/Integrations/Akamai_SIEM/Akamai_SIEM.py:121:33: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ Packs/Arkime/Integrations/Arkime/Arkime.py:1083:29: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 213 additional changes omitted for project

ibis-project/ibis (+102 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ ibis/backends/base/__init__.py:1005:53: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/base/__init__.py:1015:45: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/base/sql/compiler/translator.py:163:31: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/base/sqlglot/__init__.py:16:36: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/base/sqlglot/__init__.py:93:6: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/bigquery/__init__.py:725:17: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/bigquery/udf/__init__.py:203:10: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/bigquery/udf/__init__.py:325:10: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/bigquery/udf/__init__.py:40:10: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ ibis/backends/bigquery/udf/core.py:55:18: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
... 92 additional changes omitted for project

pypa/build (+6 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ src/build/__init__.py:139:37: UP006 Use `collections.abc.Sequence` instead of `Sequence` for type annotation
+ src/build/__init__.py:139:84: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ src/build/__init__.py:59:28: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ src/build/__init__.py:80:45: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ src/build/__init__.py:94:47: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation
+ src/build/__init__.py:94:69: UP006 Use `collections.abc.Mapping` instead of `Mapping` for type annotation

pypa/cibuildwheel (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ test/conftest.py:35:25: UP006 Use `collections.abc.Generator` instead of `Generator` for type annotation

python/mypy (+516 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

+ misc/analyze_cache.py:37:29: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:37:53: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:38:25: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:38:48: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:64:29: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:74:30: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/analyze_cache.py:74:53: UP006 Use `collections.abc.Iterable` instead of `Iterable` for type annotation
+ misc/perf_checker.py:15:31: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ misc/perf_checker.py:15:60: UP006 Use `collections.abc.Callable` instead of `Callable` for type annotation
+ misc/upload-pypi.py:100:20: UP006 Use `collections.abc.Iterator` instead of `Iterator` for type annotation
... 506 additional changes omitted for project

... Truncated remaining completed projected reports due to GitHub comment length restrictions

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
UP006 4505 4505 0 0 0
FA100 835 835 0 0 0

@zanieb
Copy link
Member

zanieb commented Mar 12, 2024

@AlexWaygood @charliermarsh could you two work together to determine a path forward on this one?

@charliermarsh
Copy link
Member

Ok, I think it actually does make sense to add these here -- but they probably need to go under preview. You're right that it's silly that the first case triggers, but the second does not:

from typing import AbstractSet

def f(x: AbstractSet[str]) -> None:
    pass

import typing

def f(x: typing.AbstractSet[str]) -> None:
    pass

@charliermarsh
Copy link
Member

If you want to rebase and gate the new variants behind preview, I am happy to merge the change.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of Charlie's comment

If you want to rebase and gate the new variants behind preview, I am happy to merge the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support flake8-pep585 for accesses from typing after import
5 participants