Skip to content

Commit

Permalink
Skip to format files under venv and env (#2708)
Browse files Browse the repository at this point in the history
* update black

* changelog

* update

* review
  • Loading branch information
msyyc authored Jul 23, 2024
1 parent 6f7abf2 commit ca805ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/exclue-venv-2024-6-22-15-39-49.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@azure-tools/typespec-python"
---

Skip to format files under `venv`/`env` and any folder start with `.`
2 changes: 1 addition & 1 deletion packages/typespec-python/generator/pygen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def write_file(self, filename: Union[str, Path], file_content: str) -> None:
fd.write(file_content)

def list_file(self) -> List[str]:
return [str(f) for f in self.output_folder.glob("**/*") if f.is_file()]
return [str(f.relative_to(self.output_folder)) for f in self.output_folder.glob("**/*") if f.is_file()]


class Plugin(ReaderAndWriter, ABC):
Expand Down
15 changes: 7 additions & 8 deletions packages/typespec-python/generator/pygen/black.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ def process(self) -> bool:
[
Path(f)
for f in self.list_file()
if all(
item not in f
for item in (
"__pycache__",
"node_modules",
".tox",
".mypy_cache",
)
if Path(f).parts[0]
not in (
"__pycache__",
"node_modules",
"venv",
"env",
)
and not Path(f).parts[0].startswith(".")
and Path(f).suffix == ".py"
],
)
Expand Down

0 comments on commit ca805ac

Please sign in to comment.