Skip to content
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

Improve conan inspect output, it now understands set_name/set_version #13716

Merged
merged 11 commits into from
Apr 21, 2023

Conversation

AbrilRBS
Copy link
Member

@AbrilRBS AbrilRBS commented Apr 18, 2023

Changelog: Feature: Improve conan inspect output, it now understands set_name/set_version.
Docs: conan-io/docs#3204

conan inspect now parses the conanfile and returns its serialization

Close #13628

@AbrilRBS AbrilRBS requested a review from memsharded April 18, 2023 14:05
@AbrilRBS AbrilRBS self-assigned this Apr 18, 2023
@AbrilRBS AbrilRBS marked this pull request as draft April 18, 2023 19:47
Copy link
Member

@memsharded memsharded 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, just a couple of open issues about serialization to discuss.

conan/cli/commands/inspect.py Outdated Show resolved Hide resolved
conans/model/conan_file.py Outdated Show resolved Hide resolved
from conan.cli.formatters import default_json_formatter


def inspect_text_formatter(data):
for name, value in data.items():
for name, value in sorted(data.items(), key=lambda x: x[0]):
Copy link
Member

Choose a reason for hiding this comment

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

why this lambda? Not very intuitive

Copy link
Member Author

Choose a reason for hiding this comment

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

While playing with the output I realized it would be insertion-order dependant and implemented a sort on the items to have them show up alphabetically. Maybe we want to have a custom order and just have to be carefurl about when we insert the result in the serialization?

Copy link
Member

Choose a reason for hiding this comment

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

Still not sure. sorted(mydict.items()) already sorts by the first element (key), no need for the lambda

@AbrilRBS AbrilRBS changed the title [wip] Different approaches for new conan inspect Improve conan inspect output, it now understands set_name/set_version Apr 19, 2023
if self.version is not None:
result["version"] = str(self.version)
if self.topics is not None:
result["topics"] = list(self.topics)
Copy link
Member Author

Choose a reason for hiding this comment

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

Not happy about this, but some tests were failing when calling graph create for json formatter (test/integration/command/create_test.py:475). I do wonder why now and not with the old changes the also has the topics returned

@AbrilRBS AbrilRBS marked this pull request as ready for review April 19, 2023 18:36
for a in ("name", "user", "channel", "url", "license",
"author", "description", "homepage", "build_policy", "upload_policy",
"revision_mode", "provides", "deprecated", "win_bash", "win_bash_run",
"default_options", "options_description", "generators", "requires"):
Copy link
Member

Choose a reason for hiding this comment

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

Serialization of the requires field is a bit uncertain how is being serialized, as it is a Python Requirements object?

@memsharded memsharded added this to the 2.0.5 milestone Apr 20, 2023
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.

conan v2: Expose conan inspect through the API to access attributes
2 participants