0.1.0 add support for .gitignore and --relative-imports (#1)
Some checks failed
Release / release (push) Failing after 22s
Some checks failed
Release / release (push) Failing after 22s
* ignore .gitignore * remove relative imports * remove tmp * rename template string * rename template string * format with black * changelog * Bump version: 0.0.0.dev1 → 0.0.0.dev2 * bump version * Bump version: 0.1.0 → 0.2.0.dev0 * Bump version: 0.2.0.dev0 → 0.2.0.dev1 --------- Co-authored-by: autobump <autobump@users.noreply.github.com>
This commit is contained in:
parent
18440d57dd
commit
7c7877795f
8 changed files with 30 additions and 8 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -496,6 +496,9 @@ poetry.toml
|
|||
# ruff
|
||||
.ruff_cache/
|
||||
|
||||
# LSP config files
|
||||
pyrightconfig.json
|
||||
|
||||
### SublimeText ###
|
||||
# Cache files for Sublime Text
|
||||
*.tmlanguage.cache
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
## 0.1.0
|
||||
|
||||
- feat ignore files in .gitignore
|
||||
- feat `--relative-imports` flag
|
||||
|
||||
## 0.0.0
|
||||
|
||||
init
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
Generates pyflyby configurations for your project based on existing imports.
|
||||
|
||||
[](https://pypi.org/project/{{ package_name }})
|
||||
[](https://pypi.org/project/{{ package_name }})
|
||||
[](https://pypi.org/project/pyflybygen)
|
||||
[](https://pypi.org/project/pyflybygen)
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# SPDX-FileCopyrightText: 2023-present Waylon S. Walker <waylon@waylonwalker.com>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
__version__ = "0.0.0"
|
||||
__version__ = "0.2.0.dev1"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from pathlib import Path
|
||||
|
||||
import more_itertools
|
||||
import pathspec
|
||||
import typer
|
||||
|
||||
from pyflybygen.cli.common import verbose_callback
|
||||
|
|
@ -48,10 +49,20 @@ def main(
|
|||
callback=verbose_callback,
|
||||
help="show the log messages",
|
||||
),
|
||||
relative_imports: bool = typer.Option(
|
||||
False,
|
||||
help="include relative imports",
|
||||
),
|
||||
) -> None:
|
||||
imports = more_itertools.flatten(
|
||||
[get_imports(p.read_text()) for p in Path(".").glob("**/*.py")]
|
||||
)
|
||||
lines = []
|
||||
if Path(".gitignore").exists():
|
||||
lines.extend(Path(".gitignore").read_text().splitlines())
|
||||
spec = pathspec.PathSpec.from_lines("gitwildmatch", lines)
|
||||
files = Path(".").glob("**/*.py")
|
||||
files = [file for file in files if not spec.match_file(str(file))]
|
||||
imports = more_itertools.flatten([get_imports(p.read_text()) for p in files])
|
||||
if not relative_imports:
|
||||
imports = [i for i in imports if "from ." not in i]
|
||||
print("\n".join(set(imports)))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ dependencies = [
|
|||
"anyconfig",
|
||||
"tree_sitter_languages",
|
||||
'more_itertools',
|
||||
'coverage',
|
||||
'coverage-rich',
|
||||
'pathspec',
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
|
|
@ -58,6 +57,8 @@ dependencies = [
|
|||
"pytest-rich",
|
||||
"ruff",
|
||||
"black",
|
||||
'coverage',
|
||||
'coverage-rich',
|
||||
]
|
||||
[tool.hatch.envs.default.scripts]
|
||||
test = "coverage run -m pytest"
|
||||
|
|
|
|||
2
tmp.py
2
tmp.py
|
|
@ -1,5 +1,7 @@
|
|||
from pathlib import Path
|
||||
|
||||
from .pyflybygen import pyflybygen
|
||||
|
||||
statements = """
|
||||
from __future__ import (absolute_import,
|
||||
division)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue