Skip to content

Commit

Permalink
Enforce double quotes by removing skip-string-normalization from blac…
Browse files Browse the repository at this point in the history
…k config
  • Loading branch information
filipchristiansen committed Dec 28, 2024
1 parent 16c8abf commit 18444c3
Show file tree
Hide file tree
Showing 15 changed files with 195 additions and 196 deletions.
34 changes: 17 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@ repos:
hooks:
# Files
- id: check-added-large-files
description: 'Prevent large files from being committed.'
args: ['--maxkb=10000']
description: "Prevent large files from being committed."
args: ["--maxkb=10000"]
- id: check-case-conflict
description: 'Check for files that would conflict in case-insensitive filesystems.'
description: "Check for files that would conflict in case-insensitive filesystems."
- id: fix-byte-order-marker
description: 'Remove utf-8 byte order marker.'
description: "Remove utf-8 byte order marker."
- id: mixed-line-ending
description: 'Replace mixed line ending.'
description: "Replace mixed line ending."

# Links
- id: destroyed-symlinks
description: 'Detect symlinks which are changed to regular files with a content of a path which that symlink was pointing to.'
description: "Detect symlinks which are changed to regular files with a content of a path which that symlink was pointing to."

# File files for parseable syntax: python
- id: check-ast

# File and line endings
- id: end-of-file-fixer
description: 'Ensure that a file is either empty, or ends with one newline.'
description: "Ensure that a file is either empty, or ends with one newline."
- id: trailing-whitespace
description: 'Trim trailing whitespace.'
description: "Trim trailing whitespace."

# Python
- id: check-docstring-first
description: 'Check a common error of defining a docstring after code.'
description: "Check a common error of defining a docstring after code."
- id: requirements-txt-fixer
description: 'Sort entries in requirements.txt.'
description: "Sort entries in requirements.txt."

- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
description: 'Automatically convert relative imports to absolute. (Use `args: [--never]` to revert.)'
description: "Automatically convert relative imports to absolute. (Use `args: [--never]` to revert.)"

- repo: https://github.com/psf/black
rev: 24.10.0
Expand All @@ -47,30 +47,30 @@ repos:
rev: v3.19.1
hooks:
- id: pyupgrade
description: 'Automatically upgrade syntax for newer versions.'
description: "Automatically upgrade syntax for newer versions."
args: [--py3-plus, --py36-plus, --py38-plus, --py39-plus, --py310-plus]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
description: 'Enforce that `noqa` annotations always occur with specific codes. Sample annotations: `# noqa: F401`, `# noqa: F401,W203`.'
description: "Enforce that `noqa` annotations always occur with specific codes. Sample annotations: `# noqa: F401`, `# noqa: F401,W203`."
- id: python-check-blanket-type-ignore
description: 'Enforce that `# type: ignore` annotations always occur with specific codes. Sample annotations: `# type: ignore[attr-defined]`, `# type: ignore[attr-defined, name-defined]`.'
description: "Enforce that `# type: ignore` annotations always occur with specific codes. Sample annotations: `# type: ignore[attr-defined]`, `# type: ignore[attr-defined, name-defined]`."
- id: python-use-type-annotations
description: 'Enforce that python3.6+ type annotations are used instead of type comments.'
description: "Enforce that python3.6+ type annotations are used instead of type comments."

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
description: 'Sort imports alphabetically, and automatically separated into sections and by type.'
description: "Sort imports alphabetically, and automatically separated into sections and by type."

- repo: https://github.com/hadialqattan/pycln
rev: v2.4.0
hooks:
- id: pycln
description: 'Remove unused import statements.'
description: "Remove unused import statements."

- repo: https://github.com/djlint/djLint
rev: v1.36.4
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ filter_files = true

[tool.black]
line-length = 119
skip-string-normalization = true
12 changes: 6 additions & 6 deletions src/gitingest/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def normalize_pattern(pattern: str) -> str:


@click.command()
@click.argument('source', type=str, required=True)
@click.option('--output', '-o', default=None, help='Output file path (default: <repo_name>.txt in current directory)')
@click.option('--max-size', '-s', default=MAX_FILE_SIZE, help='Maximum file size to process in bytes')
@click.option('--exclude-pattern', '-e', multiple=True, help='Patterns to exclude')
@click.option('--include-pattern', '-i', multiple=True, help='Patterns to include')
@click.argument("source", type=str, required=True)
@click.option("--output", "-o", default=None, help="Output file path (default: <repo_name>.txt in current directory)")
@click.option("--max-size", "-s", default=MAX_FILE_SIZE, help="Maximum file size to process in bytes")
@click.option("--exclude-pattern", "-e", multiple=True, help="Patterns to exclude")
@click.option("--include-pattern", "-i", multiple=True, help="Patterns to include")
def main(
source: str,
output: str | None,
Expand All @@ -46,5 +46,5 @@ def main(
raise click.Abort()


if __name__ == '__main__':
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion src/gitingest/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async def clone_repo(config: CloneConfig) -> tuple[bytes, bytes]:
checkout_cmd = ["git", "-C", local_path, "checkout", commit]
return await run_git_command(*checkout_cmd)

if branch and branch.lower() not in ('main', 'master'):
if branch and branch.lower() not in ("main", "master"):
# Scenario 2: Clone a specific branch with shallow depth
clone_cmd = ["git", "clone", "--depth=1", "--single-branch", "--branch", branch, url, local_path]
return await run_git_command(*clone_cmd)
Expand Down
168 changes: 84 additions & 84 deletions src/gitingest/ignore_patterns.py
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
DEFAULT_IGNORE_PATTERNS: list[str] = [
# Python
'*.pyc',
'*.pyo',
'*.pyd',
'__pycache__',
'.pytest_cache',
'.coverage',
'.tox',
'.nox',
'.mypy_cache',
'.ruff_cache',
'.hypothesis',
'poetry.lock',
'Pipfile.lock',
"*.pyc",
"*.pyo",
"*.pyd",
"__pycache__",
".pytest_cache",
".coverage",
".tox",
".nox",
".mypy_cache",
".ruff_cache",
".hypothesis",
"poetry.lock",
"Pipfile.lock",
# JavaScript/Node
'node_modules',
'bower_components',
'package-lock.json',
'yarn.lock',
'.npm',
'.yarn',
'.pnpm-store',
"node_modules",
"bower_components",
"package-lock.json",
"yarn.lock",
".npm",
".yarn",
".pnpm-store",
# Version control
'.git',
'.svn',
'.hg',
'.gitignore',
'.gitattributes',
'.gitmodules',
".git",
".svn",
".hg",
".gitignore",
".gitattributes",
".gitmodules",
# Images and media
'*.svg',
'*.png',
'*.jpg',
'*.jpeg',
'*.gif',
'*.ico',
'*.pdf',
'*.mov',
'*.mp4',
'*.mp3',
'*.wav',
"*.svg",
"*.png",
"*.jpg",
"*.jpeg",
"*.gif",
"*.ico",
"*.pdf",
"*.mov",
"*.mp4",
"*.mp3",
"*.wav",
# Virtual environments
'venv',
'.venv',
'env',
'.env',
'virtualenv',
"venv",
".venv",
"env",
".env",
"virtualenv",
# IDEs and editors
'.idea',
'.vscode',
'.vs',
'*.swp',
'*.swo',
'*.swn',
'.settings',
'.project',
'.classpath',
'*.sublime-*',
".idea",
".vscode",
".vs",
"*.swp",
"*.swo",
"*.swn",
".settings",
".project",
".classpath",
"*.sublime-*",
# Temporary and cache files
'*.log',
'*.bak',
'*.swp',
'*.tmp',
'*.temp',
'.cache',
'.sass-cache',
'.eslintcache',
'.DS_Store',
'Thumbs.db',
'desktop.ini',
"*.log",
"*.bak",
"*.swp",
"*.tmp",
"*.temp",
".cache",
".sass-cache",
".eslintcache",
".DS_Store",
"Thumbs.db",
"desktop.ini",
# Build directories and artifacts
'build',
'dist',
'target',
'out',
'*.egg-info',
'*.egg',
'*.whl',
'*.so',
'*.dylib',
'*.dll',
'*.class',
"build",
"dist",
"target",
"out",
"*.egg-info",
"*.egg",
"*.whl",
"*.so",
"*.dylib",
"*.dll",
"*.class",
# Documentation
'site-packages',
'.docusaurus',
'.next',
'.nuxt',
"site-packages",
".docusaurus",
".next",
".nuxt",
# Other common patterns
## Minified files
'*.min.js',
'*.min.css',
"*.min.js",
"*.min.css",
## Source maps
'*.map',
"*.map",
## Terraform
'.terraform',
'*.tfstate*',
".terraform",
"*.tfstate*",
## Dependencies in various languages
'vendor/',
"vendor/",
]
12 changes: 6 additions & 6 deletions src/gitingest/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def ingest(
include_patterns=include_patterns,
ignore_patterns=exclude_patterns,
)
if query['url']:
if query["url"]:

# Extract relevant fields for CloneConfig
clone_config = CloneConfig(
url=f"https://github.com/{query['slug']}.git",
local_path=query['local_path'],
commit=query.get('commit'),
branch=query.get('branch'),
local_path=query["local_path"],
commit=query.get("commit"),
branch=query.get("branch"),
)
clone_result = clone_repo(clone_config)

Expand All @@ -49,7 +49,7 @@ def ingest(

finally:
# Clean up the temporary directory if it was created
if query['url']:
if query["url"]:
# Get parent directory two levels up from local_path (../tmp)
cleanup_path = str(Path(query['local_path']).parents[1])
cleanup_path = str(Path(query["local_path"]).parents[1])
shutil.rmtree(cleanup_path, ignore_errors=True)
Loading

0 comments on commit 18444c3

Please sign in to comment.