in keyword in class method causes indentation problem
See original GitHub issueDescription
Class with a function named “in” causes indentation issue:
Input
The code looked like this before beautification:
class {
get a() {
}
in () {
}
b () {
}
}
Expected Output
The code should have looked like this after beautification:
(should be unchanged)
Actual Output
The code actually looked like this after beautification:
class {
get a() {
}
in () {
}
b() {
}
}
Steps to Reproduce
Tried on https://beautifier.io/
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Having trouble with class methods - python - Stack Overflow
Based on your indention, you're defining your methods in your init method. Unindent them so they're the same level as your init method...
Read more >Indentation Error in Python | How to Solve it - Edureka
As mentioned in the introduction paragraph, one of the main reasons for the indentation error is the absence of tabs and or whitespaces...
Read more >How does Indentation Error Work in Python? - eduCBA
It happens mainly because of the absence of tabs and whitespaces between the lines of code. If there are any missing spaces between...
Read more >How to fix indentation Error in Python - Numpy Ninja
Below are some of the common causes of an indentation error in Python: While coding you are using both the tab as well...
Read more >Indentation - Washington
has 1 level of indentation, a loop in a method in a class has 2 levels of ... implementation details makes it difficult...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe I figured out the answer to my question above.
I am now working on this change. I will keep you all updated on my progress!
Yes, to test this, I reverted my changes to
tokenizer.py
and ran bothmake
andmake all
(not sure if there’s a difference there). Neither resulted in a failure, and within themake all
output, I do see:which I think means that no Python tests failed even after I reverted my changes in
tokenizer.py
. I also ranmake py
, which resulted in “PASSED”.Looking into this further, I can actually see that my unit tests were automatically generated in
python/jsbeautifier/tests/generated/tests.py
like you said, so I feel like it’s strange that no Python tests failed. FWIW, I know the JavaScript unit tests I wrote failed before I made changes to the JavaScript implementation.I know I can’t make changes to
python/jsbeautifier/tests/generated/tests.py
as it is automatically generated. So, what’s the best way to write good unit tests to make sure this bug doesn’t reoccur in the future? (For now, like I mentioned, I’ve just had to run./tools/python-dev js-beautify
on a local .js file I made to see if the bug is still present in the Python implementation.)