Compare commits

...

8 commits

Author SHA1 Message Date
autobump
e653516b75 Bump version: 0.0.0.dev1 → 0.0.0.dev2
Some checks failed
Release / release (push) Failing after 12s
2023-03-13 15:21:01 +00:00
623c41e236
changelog 2023-03-13 10:19:24 -05:00
b37a4b6e59
format with black 2023-03-13 10:18:24 -05:00
a9861eb082
rename template string 2023-03-13 10:16:59 -05:00
f86cb023f1
rename template string 2023-03-13 10:16:55 -05:00
6b811ec0c6
remove tmp 2023-03-13 10:14:56 -05:00
cf757847ad
remove relative imports 2023-03-13 10:14:34 -05:00
6950680ee9
ignore .gitignore 2023-03-13 10:08:14 -05:00
8 changed files with 30 additions and 8 deletions

3
.gitignore vendored
View file

@ -496,6 +496,9 @@ poetry.toml
# ruff # ruff
.ruff_cache/ .ruff_cache/
# LSP config files
pyrightconfig.json
### SublimeText ### ### SublimeText ###
# Cache files for Sublime Text # Cache files for Sublime Text
*.tmlanguage.cache *.tmlanguage.cache

View file

@ -1,3 +1,8 @@
## 0.1.0
- feat ignore files in .gitignore
- feat `--relative-imports` flag
## 0.0.0 ## 0.0.0
init init

View file

@ -2,8 +2,8 @@
Generates pyflyby configurations for your project based on existing imports. Generates pyflyby configurations for your project based on existing imports.
[![PyPI - Version](https://img.shields.io/pypi/v/{{ package_name }}.svg)](https://pypi.org/project/{{ package_name }}) [![PyPI - Version](https://img.shields.io/pypi/v/pyflybygen.svg)](https://pypi.org/project/pyflybygen)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/{{ package_name }}.svg)](https://pypi.org/project/{{ package_name }}) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyflybygen.svg)](https://pypi.org/project/pyflybygen)
--- ---

View file

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023-present Waylon S. Walker <waylon@waylonwalker.com> # SPDX-FileCopyrightText: 2023-present Waylon S. Walker <waylon@waylonwalker.com>
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
__version__ = "0.0.0.dev1" __version__ = "0.0.0.dev2"

View file

@ -1,6 +1,7 @@
from pathlib import Path from pathlib import Path
import more_itertools import more_itertools
import pathspec
import typer import typer
from pyflybygen.cli.common import verbose_callback from pyflybygen.cli.common import verbose_callback
@ -48,10 +49,20 @@ def main(
callback=verbose_callback, callback=verbose_callback,
help="show the log messages", help="show the log messages",
), ),
relative_imports: bool = typer.Option(
False,
help="include relative imports",
),
) -> None: ) -> None:
imports = more_itertools.flatten( lines = []
[get_imports(p.read_text()) for p in Path(".").glob("**/*.py")] 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))) print("\n".join(set(imports)))

View file

@ -30,8 +30,7 @@ dependencies = [
"anyconfig", "anyconfig",
"tree_sitter_languages", "tree_sitter_languages",
'more_itertools', 'more_itertools',
'coverage', 'pathspec',
'coverage-rich',
] ]
dynamic = ["version"] dynamic = ["version"]
@ -58,6 +57,8 @@ dependencies = [
"pytest-rich", "pytest-rich",
"ruff", "ruff",
"black", "black",
'coverage',
'coverage-rich',
] ]
[tool.hatch.envs.default.scripts] [tool.hatch.envs.default.scripts]
test = "coverage run -m pytest" test = "coverage run -m pytest"

2
tmp.py
View file

@ -1,5 +1,7 @@
from pathlib import Path from pathlib import Path
from .pyflybygen import pyflybygen
statements = """ statements = """
from __future__ import (absolute_import, from __future__ import (absolute_import,
division) division)