mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 18:54:59 +00:00
style: Format watch.py with black and add newlines between functions
This commit is contained in:
parent
81903598a8
commit
21876e72fe
1 changed files with 33 additions and 7 deletions
|
@ -1,7 +1,9 @@
|
|||
from pathlib import Path
|
||||
from typing import Set
|
||||
|
||||
from watchfiles import watch
|
||||
|
||||
|
||||
def is_source_file(path: Path) -> bool:
|
||||
"""
|
||||
Check if a file is a source file that uses # or // style comments.
|
||||
|
@ -9,13 +11,35 @@ def is_source_file(path: Path) -> bool:
|
|||
"""
|
||||
COMMENT_STYLE_EXTENSIONS = {
|
||||
# # style comments
|
||||
'.py', '.r', '.rb', '.pl', '.pm', '.sh', '.bash', '.yaml', '.yml',
|
||||
".py",
|
||||
".r",
|
||||
".rb",
|
||||
".pl",
|
||||
".pm",
|
||||
".sh",
|
||||
".bash",
|
||||
".yaml",
|
||||
".yml",
|
||||
# // style comments
|
||||
'.js', '.ts', '.jsx', '.tsx', '.cpp', '.c', '.h', '.hpp', '.java',
|
||||
'.swift', '.kt', '.cs', '.go', '.rs', '.php'
|
||||
".js",
|
||||
".ts",
|
||||
".jsx",
|
||||
".tsx",
|
||||
".cpp",
|
||||
".c",
|
||||
".h",
|
||||
".hpp",
|
||||
".java",
|
||||
".swift",
|
||||
".kt",
|
||||
".cs",
|
||||
".go",
|
||||
".rs",
|
||||
".php",
|
||||
}
|
||||
return path.suffix.lower() in COMMENT_STYLE_EXTENSIONS
|
||||
|
||||
|
||||
def watch_source_files(directory: str) -> Set[str]:
|
||||
"""
|
||||
Watch for changes to source files in the given directory and its subdirectories.
|
||||
|
@ -33,6 +57,7 @@ def watch_source_files(directory: str) -> Set[str]:
|
|||
changed_files = {str(Path(change[1])) for change in changes}
|
||||
yield changed_files
|
||||
|
||||
|
||||
def main():
|
||||
"""Example usage of the file watcher"""
|
||||
import sys
|
||||
|
@ -52,5 +77,6 @@ def main():
|
|||
except KeyboardInterrupt:
|
||||
print("\nStopped watching files")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue