Skip to content

Commit

Permalink
Always allow PEP 585 and PEP 604 rewrites in stub files (#5653)
Browse files Browse the repository at this point in the history
Closes #5640.
  • Loading branch information
charliermarsh committed Jul 10, 2023
1 parent 35b04c2 commit ed87214
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions crates/ruff/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2161,7 +2161,8 @@ where
}
}
if self.enabled(Rule::NonPEP604Annotation) {
if self.settings.target_version >= PythonVersion::Py310
if self.is_stub
|| self.settings.target_version >= PythonVersion::Py310
|| (self.settings.target_version >= PythonVersion::Py37
&& self.semantic.future_annotations()
&& self.semantic.in_annotation()
Expand Down Expand Up @@ -2289,7 +2290,8 @@ where
}
}
if self.enabled(Rule::NonPEP585Annotation) {
if self.settings.target_version >= PythonVersion::Py39
if self.is_stub
|| self.settings.target_version >= PythonVersion::Py39
|| (self.settings.target_version >= PythonVersion::Py37
&& self.semantic.future_annotations()
&& self.semantic.in_annotation()
Expand Down Expand Up @@ -2367,7 +2369,8 @@ where
}
}
if self.enabled(Rule::NonPEP585Annotation) {
if self.settings.target_version >= PythonVersion::Py39
if self.is_stub
|| self.settings.target_version >= PythonVersion::Py39
|| (self.settings.target_version >= PythonVersion::Py37
&& self.semantic.future_annotations()
&& self.semantic.in_annotation()
Expand Down Expand Up @@ -2540,10 +2543,10 @@ where
if self.enabled(Rule::OSErrorAlias) {
pyupgrade::rules::os_error_alias_call(self, func);
}
if self.enabled(Rule::NonPEP604Isinstance)
&& self.settings.target_version >= PythonVersion::Py310
{
pyupgrade::rules::use_pep604_isinstance(self, expr, func, args);
if self.enabled(Rule::NonPEP604Isinstance) {
if self.settings.target_version >= PythonVersion::Py310 {
pyupgrade::rules::use_pep604_isinstance(self, expr, func, args);
}
}
if self.enabled(Rule::BlockingHttpCallInAsyncFunction) {
flake8_async::rules::blocking_http_call(self, expr);
Expand Down

0 comments on commit ed87214

Please sign in to comment.