Repository: hhatto/autopep8

Issue:
Some E265 errors won't be fixed
---

## Python Code
```python
#print(" ")
```

## Command Line and Configuration
Config:
N/A

Command Line
```shell
$ autopep8 --diff --select=E265 foo.py
```


## Your Environment
* Python version: 3.10.9
* autopep8 version: 1.7.1 (pycodestyle: 2.9.1)
* Platform: WSL on Windows 10 Pro

The following environment has the same issue:
* Python version: 3.10.9
* autopep8 version: 2.0.0 (pycodestyle: 2.10.0)
* Platform: WSL on Windows 10 Pro

## Extra Information

The following code can be fixed (without a space between quotes):

```python
#print("")
```

```console
% autopep8 --diff --select=E265 foo.py
--- original/foo.py
+++ fixed/foo.py
@@ -1 +1 @@
-#print("")
+# print("")
```



Discussion:

Patch:
diff --git a/autopep8.py b/autopep8.py
index 27809fc..75cb27d 100755
--- a/autopep8.py
+++ b/autopep8.py
@@ -3330,7 +3330,7 @@ def filter_results(source, results, aggressive):
                 continue
 
         if r['line'] in commented_out_code_line_numbers:
-            if issue_id.startswith(('e26', 'e501')):
+            if issue_id.startswith(('e261', 'e262', 'e501')):
                 continue
 
         # Do not touch indentation if there is a token error caused by


Test patch:
diff --git a/test/test_autopep8.py b/test/test_autopep8.py
index 64d30eb..5f4dbed 100755
--- a/test/test_autopep8.py
+++ b/test/test_autopep8.py
@@ -271,7 +271,7 @@ def foo():
         commented_out_code = '#x = 1'
         self.assertEqual(
             commented_out_code,
-            fix_e265_and_e266(commented_out_code))
+            fix_e266(commented_out_code))
 
     def test_fix_file(self):
         self.assertIn(
@@ -2238,6 +2238,12 @@ bar[zap[0][0]:zig[0][0], :]
         with autopep8_context(line, options=['--select=E265']) as result:
             self.assertEqual(fixed, result)
 
+    def test_e265_issue662(self):
+        line = "#print(\" \")\n"
+        fixed = "# print(\" \")\n"
+        with autopep8_context(line, options=['--select=E265']) as result:
+            self.assertEqual(fixed, result)
+
     def test_ignore_e265(self):
         line = "## A comment\n#B comment\n123\n"
         fixed = "# A comment\n#B comment\n123\n"
@@ -2256,6 +2262,12 @@ bar[zap[0][0]:zig[0][0], :]
         with autopep8_context(line, options=['--select=E266']) as result:
             self.assertEqual(fixed, result)
 
+    def test_e266_issue662(self):
+        line = "## comment\n"
+        fixed = "# comment\n"
+        with autopep8_context(line) as result:
+            self.assertEqual(fixed, result)
+
     def test_ignore_e266(self):
         line = "##A comment\n#B comment\n123\n"
         fixed = "## A comment\n# B comment\n123\n"
@@ -3167,7 +3179,7 @@ if True:
 # http://foo.bar/abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-
 
 # The following is ugly commented-out code and should not be touched.
-#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 1
+# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 1
 """
         with autopep8_context(line, options=['--aggressive']) as result:
             self.assertEqual(fixed, result)
@@ -6442,7 +6454,7 @@ if True:
 # http://foo.bar/abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-
 
 # The following is ugly commented-out code and should not be touched.
-#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 1
+# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 1
 """
         with autopep8_context(line, options=['--experimental',
                                              '--aggressive']) as result:
@@ -7287,6 +7299,11 @@ if True:
             self.assertEqual(fixed, result)
 
 
+def fix_e266(source):
+    with autopep8_context(source, options=['--select=E266']) as result:
+        return result
+
+
 def fix_e265_and_e266(source):
     with autopep8_context(source, options=['--select=E265,E266']) as result:
         return result