-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support custom toml
path
#581
base: main
Are you sure you want to change the base?
Conversation
@@ -21,17 +20,7 @@ | |||
TachSetupError, | |||
TachVisibilityError, | |||
) | |||
from tach.extension import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoiding direct imports for functions so we can directly mock without including the cli
module in the path for the mocked function. When you import directly like this instead of mocking tach.extension.my_func
you mock the cli
module which can be a little bit awkward. The Google Python style guide additionally recommends this:
Use import statements for packages and modules only, not for individual types, classes, or functions.
Let me know if we're fine with this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works for me 👍
2b2ba63
to
e2278f9
Compare
9763b81
to
e26a23b
Compare
def main() -> None: | ||
args, parser = parse_arguments(sys.argv[1:]) | ||
def main(argv: list[str] = sys.argv[1:]) -> None: | ||
args, parser = parse_arguments(argv) | ||
project_root = fs.find_project_config_root() or Path.cwd() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the use case in #579 , we also need to adjust the project_root
which is passed to tach_server
based on the location of the actual config file. This is needed for Tach to correctly interpret source_roots
and differentiate between first-party and third-party imports.
I believe the config parsing code in Rust tracks the location of the config file, but it would be better for now to just adjust the usage of find_project_config_root
in main
to handle this specific LSP case.
except Exception as e: | ||
print(f"Failed to parse project config: {e}") | ||
sys.exit(1) | ||
|
||
|
||
def main() -> None: | ||
args, parser = parse_arguments(sys.argv[1:]) | ||
def main(argv: list[str] = sys.argv[1:]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge deal because direct CLI usage is unlikely, but in this function there is a call to print_no_config_found
which should now take the custom config argument so that the error message can be more accurate. Right now it will always say tach.toml
is not found, even when specifying another name.
This PR adds support for custom
tach.toml
paths for alltach server
for usage in the VSCode plugin.