auto-code-fixer 0.2.4__tar.gz → 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/PKG-INFO +1 -1
  2. auto_code_fixer-0.2.5/auto_code_fixer/__init__.py +2 -0
  3. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer/cli.py +20 -1
  4. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer/runner.py +10 -7
  5. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer.egg-info/PKG-INFO +1 -1
  6. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/pyproject.toml +1 -1
  7. auto_code_fixer-0.2.4/auto_code_fixer/__init__.py +0 -2
  8. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/LICENSE +0 -0
  9. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/README.md +0 -0
  10. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer/fixer.py +0 -0
  11. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer/guard.py +0 -0
  12. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer/installer.py +0 -0
  13. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer/utils.py +0 -0
  14. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer.egg-info/SOURCES.txt +0 -0
  15. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer.egg-info/dependency_links.txt +0 -0
  16. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer.egg-info/entry_points.txt +0 -0
  17. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer.egg-info/requires.txt +0 -0
  18. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/auto_code_fixer.egg-info/top_level.txt +0 -0
  19. {auto_code_fixer-0.2.4 → auto_code_fixer-0.2.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: auto-code-fixer
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Automatically fix Python code using ChatGPT
5
5
  Author-email: Arif Shah <ashah7775@gmail.com>
6
6
  License: MIT
@@ -0,0 +1,2 @@
1
+ __version__ = "0.2.5"
2
+
@@ -97,7 +97,26 @@ def fix_file(file_path, project_root, api_key, ask, verbose):
97
97
  log("GPT returned no changes. Stopping.", "WARN")
98
98
  break
99
99
 
100
- # 🔑 UPDATE MEMORY FIRST
100
+ import ast
101
+
102
+ # Validate GPT output BEFORE accepting it
103
+ try:
104
+ ast.parse(fixed_code)
105
+ except SyntaxError:
106
+ log(
107
+ "GPT returned invalid or empty Python code. Rejecting fix.",
108
+ "ERROR",
109
+ )
110
+ break
111
+
112
+ if not fixed_code.strip():
113
+ log(
114
+ "GPT returned empty code. Rejecting fix.",
115
+ "ERROR",
116
+ )
117
+ break
118
+
119
+ # ✅ SAFE: update memory only after validation
101
120
  current_code = fixed_code
102
121
 
103
122
  # then update temp file for next execution
@@ -6,13 +6,16 @@ import sys
6
6
  def run_code(script_path, project_root):
7
7
  env = os.environ.copy()
8
8
 
9
- # 🔑 THIS is the key fix
10
- if project_root:
11
- existing = env.get("PYTHONPATH", "")
12
- env["PYTHONPATH"] = (
13
- project_root + os.pathsep + existing
14
- if existing else project_root
15
- )
9
+ script_dir = os.path.dirname(script_path)
10
+
11
+ # 🔑 CRITICAL: include BOTH project root and script dir
12
+ paths = [project_root, script_dir]
13
+
14
+ existing = env.get("PYTHONPATH", "")
15
+ if existing:
16
+ paths.append(existing)
17
+
18
+ env["PYTHONPATH"] = os.pathsep.join(paths)
16
19
 
17
20
  try:
18
21
  result = subprocess.run(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: auto-code-fixer
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Automatically fix Python code using ChatGPT
5
5
  Author-email: Arif Shah <ashah7775@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "auto-code-fixer"
7
- version = "0.2.4"
7
+ version = "0.2.5"
8
8
  description = "Automatically fix Python code using ChatGPT"
9
9
  readme = "README.md"
10
10
 
@@ -1,2 +0,0 @@
1
- __version__ = "0.2.4"
2
-
File without changes