Comments (5)
I explored bytecode comparison when I first wrote the acid tests. I gave up on it once I found that things like has_key()
and in
didn't collapse into the same bytecode. But since autopep8 is now doing things a bit more complicated like shortening lines, it might be worth doing what you suggest. I suppose we would need to disable everything except whitespace, indentation, and line length changes.
By the way, the idiomatic changes I mention are basically the things 2to3 -f idioms
fixes.
from autopep8.
See 8631ecb.
from autopep8.
I should probably do a recursive comparison of the code object rather than using dis
. My current implementation with dis
is basically just checking the top-level bytecode.
from autopep8.
For the most part, this works well. But sometimes the same code section generates different, but equivalent, bytecode representations. For example
16 LOAD_CONST 338 ((('catalogue', '0001_initial'), ('customer', '0001_initial'), ('partner', '0001_initial'), ('address', '0001_initial')))
versus
16 LOAD_CONST 1 ('catalogue')
19 LOAD_CONST 2 ('0001_initial')
22 BUILD_TUPLE 2
25 LOAD_CONST 3 ('customer')
28 LOAD_CONST 2 ('0001_initial')
31 BUILD_TUPLE 2
34 LOAD_CONST 4 ('partner')
37 LOAD_CONST 2 ('0001_initial')
40 BUILD_TUPLE 2
43 LOAD_CONST 5 ('address')
46 LOAD_CONST 2 ('0001_initial')
49 BUILD_TUPLE 2
52 BUILD_TUPLE 4
from autopep8.
Comparing the AST works better.
from autopep8.
Related Issues (20)
- [pep8] options ignored when [flake8] select= is present
- Lack of new line character when autopep8 is returning back shell input to user
- "for<space><space>" gets changed to "f<space>or<space>"
- module 'pycodestyle' has no attribute 'missing_whitespace_around_operator' HOT 11
- Pre-commit repo missing the .pre-commit-hooks.yaml file HOT 2
- Using "--ignore=E302" and "--ignore=E305" at the same time HOT 1
- sdist is missing test/acid.py
- Exclude Regex is not working for formatOnSave with vscode autopep8 extension
- migrate to pyproject.toml
- missing dependency on `packaging` HOT 1
- Test failures with Python 3.12 HOT 2
- Pyproject.toml is ignored if ~/.config/pycodestyle have select key filled
- Account for whitespace-only separation of flake8 error selectors/ignores
- Problem with formatting f-strings on python3.12 HOT 20
- Argument parser errors are printed without a trailing newline HOT 1
- Should be able to run autopep8 independently of global pycodestyle config
- Some messages written to stdout instead of stderr
- --max-line-length not working.
- ModuleNotFoundError: No module named 'lib2to3' (python3.12) HOT 2
- How to ignore the two-spaces-before-comment rule ? 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 autopep8.