Skip to content

Commit 5f7ec60

Browse files
Add Python 3.7 support by reverting inline generics and removing walrus usage
1 parent fe81de1 commit 5f7ec60

File tree

15 files changed

+110
-98
lines changed

15 files changed

+110
-98
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: true
1414
matrix:
1515
os: [ubuntu-latest, macos-latest, windows-latest]
16-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
16+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
1717

1818
steps:
1919
- uses: actions/checkout@v4

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ You can also replace `hub` with `ingest` in any GitHub URL to access the corespo
2828

2929
## 📚 Requirements
3030

31-
- Python 3.9+
31+
- Python 3.7+
3232

3333
## 📦 Installation
3434

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "gitingest"
33
version = "0.1.3"
44
description="CLI tool to analyze and create text dumps of codebases for LLMs"
55
readme = {file = "README.md", content-type = "text/markdown" }
6-
requires-python = ">= 3.9"
6+
requires-python = ">= 3.7"
77
dependencies = [
88
"click>=8.0.0",
99
"tiktoken",
@@ -16,6 +16,7 @@ classifiers=[
1616
"Development Status :: 3 - Alpha",
1717
"Intended Audience :: Developers",
1818
"License :: OSI Approved :: MIT License",
19+
"Programming Language :: Python :: 3.8",
1920
"Programming Language :: Python :: 3.9",
2021
"Programming Language :: Python :: 3.10",
2122
"Programming Language :: Python :: 3.11",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"gitingest=gitingest.cli:main",
2222
],
2323
},
24-
python_requires=">=3.9",
24+
python_requires=">=3.7",
2525
author="Romain Courtois",
2626
author_email="romain@coderamp.io",
2727
description="CLI tool to analyze and create text dumps of codebases for LLMs",

src/gitingest/ignore_patterns.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
""" Default ignore patterns for Gitingest. """
22

3-
DEFAULT_IGNORE_PATTERNS: set[str] = {
3+
from typing import Set
4+
5+
DEFAULT_IGNORE_PATTERNS: Set[str] = {
46
# Python
57
"*.pyc",
68
"*.pyo",

src/gitingest/notebook_utils.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import warnings
55
from itertools import chain
66
from pathlib import Path
7-
from typing import Any, Optional
7+
from typing import Any, Dict, List, Optional
88

99
from gitingest.exceptions import InvalidNotebookError
1010

@@ -32,12 +32,13 @@ def process_notebook(file: Path, include_output: bool = True) -> str:
3232
"""
3333
try:
3434
with file.open(encoding="utf-8") as f:
35-
notebook: dict[str, Any] = json.load(f)
35+
notebook: Dict[str, Any] = json.load(f)
3636
except json.JSONDecodeError as e:
3737
raise InvalidNotebookError(f"Invalid JSON in notebook: {file}") from e
3838

3939
# Check if the notebook contains worksheets
40-
if worksheets := notebook.get("worksheets"):
40+
worksheets = notebook.get("worksheets")
41+
if worksheets:
4142
warnings.warn(
4243
"Worksheets are deprecated as of IPEP-17. Consider updating the notebook. "
4344
"(See: https://github.com/jupyter/nbformat and "
@@ -57,19 +58,20 @@ def process_notebook(file: Path, include_output: bool = True) -> str:
5758
result = ["# Jupyter notebook converted to Python script."]
5859

5960
for cell in cells:
60-
if cell_str := _process_cell(cell, include_output=include_output):
61+
cell_str = _process_cell(cell, include_output=include_output)
62+
if cell_str:
6163
result.append(cell_str)
6264

6365
return "\n\n".join(result) + "\n"
6466

6567

66-
def _process_cell(cell: dict[str, Any], include_output: bool) -> Optional[str]:
68+
def _process_cell(cell: Dict[str, Any], include_output: bool) -> Optional[str]:
6769
"""
6870
Process a Jupyter notebook cell and return the cell content as a string.
6971
7072
Parameters
7173
----------
72-
cell : dict[str, Any]
74+
cell : Dict[str, Any]
7375
The cell dictionary from a Jupyter notebook.
7476
include_output : bool
7577
Whether to include cell outputs in the generated script
@@ -101,7 +103,8 @@ def _process_cell(cell: dict[str, Any], include_output: bool) -> Optional[str]:
101103
return f'"""\n{cell_str}\n"""'
102104

103105
# Add cell output as comments
104-
if include_output and (outputs := cell.get("outputs")):
106+
outputs = cell.get("outputs")
107+
if include_output and outputs:
105108

106109
# Include cell outputs as comments
107110
output_lines = []
@@ -118,18 +121,18 @@ def _process_cell(cell: dict[str, Any], include_output: bool) -> Optional[str]:
118121
return cell_str
119122

120123

121-
def _extract_output(output: dict[str, Any]) -> list[str]:
124+
def _extract_output(output: Dict[str, Any]) -> List[str]:
122125
"""
123126
Extract the output from a Jupyter notebook cell.
124127
125128
Parameters
126129
----------
127-
output : dict[str, Any]
130+
output : Dict[str, Any]
128131
The output dictionary from a Jupyter notebook cell.
129132
130133
Returns
131134
-------
132-
list[str]
135+
List[str]
133136
The output as a list of strings.
134137
135138
Raises

0 commit comments

Comments
 (0)