Skip to content

Conversation

@fpliger
Copy link
Contributor

@fpliger fpliger commented Jan 5, 2023

Close #39

Basically:

  • renames global pyscript config pyscript.json --> .pyscriptconfig
  • renames default app config manifest.json --> pyscript.toml
  • supports app config as json or toml

@fpliger fpliger requested a review from mchilvers January 5, 2023 19:21
@fpliger fpliger requested a review from FabioRosado January 5, 2023 19:34
Copy link
Contributor

@FabioRosado FabioRosado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, added a small comment (more like a though haha)

manifest_file = app_dir / config["project_config_filename"]
with manifest_file.open("w", encoding="utf-8") as fp:
json.dump(context, fp)
if str(manifest_file).endswith(".json"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering, what do you think about using fp.name instead of converting manifest_file to a string?

I guess manifest_file is more readable tho (unless we change the fp to something haha)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point... I think I'd lean more toward what you said in terms of readability...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a method on Path, .suffix, that you might consider using instead of using string operations.

APPNAME = "pyscript"
APPAUTHOR = "python"
DEFAULT_CONFIG_FILENAME = "pyscript.json"
DEFAULT_CONFIG_FILENAME = ".pyscriptconfig"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a comment would help here to clear up the difference between the config file for the CLI itself, and the project config file? When I first looked at the code it took me a minute to see why DEFAULT_CONFIG_FILENAME didn't match the value in DEFAULT_CONFIG. Or maybe (although it is longer), always refer to them as either CLI_CONFIG_FILENAME, cli_config and PROJECT_... etc etc?

manifest_file = app_dir / config["project_config_filename"]
with manifest_file.open("w", encoding="utf-8") as fp:
json.dump(context, fp)
if str(manifest_file).endswith(".json"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming nit? The constant is called "project_config_filename" but then we use "manifest_file" for the path? Maybe "project_config_path = ..."?

with manifest_path.open() as fp:
contents = json.load(fp)
# with a default config path
manifest_path = tmp_cwd / app_name / config["project_config_filename"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto for previous comment about picking one name.

@fpliger fpliger merged commit 36f1e59 into main Jan 11, 2023
@fpliger fpliger deleted the fpliger/39_config_filename branch January 11, 2023 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI config file and Default project config file names

5 participants