Comments (7)
this was intentionally changed at some point. there are a few cases where it still leaves an else less one but when it deems it safe it can
from pyupgrade.
this was intentionally changed at some point. there are a few cases where it still leaves an else less one but when it deems it safe it can
Is it intentional that the behavior differs between the pre-commit hook and the command line, though?
Similarly, is it intentional/safe that it deletes the next comment?
from pyupgrade.
you are comparing 3.3.1 vs 3.15.0 what do you expect?
from pyupgrade.
you are comparing 3.3.1 vs 3.15.0 what do you expect?
Ok, if I update my local pyupgrade
to 3.15.0, I get consistent behavior between the two---both delete the if
block. However I still submit that there are two issues:
- The documentation is out of date
pyupgrade
incorrectly deletes the next comment after theif sys.version_info
block
from pyupgrade.
the end of the block is not well defined when there's trialing comments -- pyupgrade picks the approach based on the information the tokenization hands it -- there isn't a correct choice because people do all sorts of flavors of:
if ...:
code
# comment
etc.
the docs aren't really out of date since there are still cases where it will leave an elseless branch alone -- but enumerating them in the docs isn't useful
from pyupgrade.
the case the docs is specifically referring to (where it will introduce a syntax error) is:
if True:
if sys.version_info ...:
...
from pyupgrade.
Fair points, thanks.
from pyupgrade.
Related Issues (20)
- --keep-runtime-typing not respected when using --py310-plus HOT 2
- Python 3.12 Generics HOT 6
- Automatically remove try-except blocks. HOT 3
- Rewriting to `yield from` may introduce type errors when using pyright HOT 2
- Recognize and replace `if sys.version_info[0]` blocks HOT 4
- How to check the version of `pyupgrade`? HOT 2
- Check for "import imp" and replace with import importlib as imp? HOT 1
- Is there a python API to call pyupgrade? HOT 2
- Formatting bug? Triple-quote changed to 2x triple-quote HOT 10
- type error when change Union operator to "| operator
- type error when change "Union" operator to "|" operator HOT 1
- Remove imports for pep 585 HOT 1
- Add a documentation ? HOT 1
- Read-only mode HOT 1
- multi-line exception with duplicate BaseException and comments gives invalid code
- Don't replace string type annotations when module is only imported with TYPE_CHECKING HOT 2
- "".join(shlex.quote(...) ...) to shlex.join(...) is too eager HOT 1
- Improve documentation of supported arguments HOT 5
- --help not very helpful HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyupgrade.