-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add pyproject.toml to maintain version from Kebechet's version manager #1163
Conversation
4d50815
to
bd71123
Compare
bd71123
to
e01a54c
Compare
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.
Looks good! I'm worried about the length of adjust...
@@ -108,6 +126,7 @@ def adjust_version_in_sources( | |||
"version.py", | |||
"app.py", | |||
"wsgi.py", |
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.
WDYT about turning this into a list of tuples Tuple[str, function] where the function is based on how to process the file type. So, for all existing entries, the function would be self.adjust_version_file
, but for the new entry it would self.adjust_version_toml_file
or something like this? adjust_version_file
is getting a bit long, so I think it should be either refactored into smaller functions, or the new functionality should go in its own function. Let me know what you think.
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.
@KPostOffice I'm thinking about using dict of {file_name : function} , fetch the function based on file_name and call
e01a54c
to
7f5f697
Compare
7f5f697
to
12d3894
Compare
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.
Good approach.
12d3894
to
d7dc82a
Compare
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.
some more suggestions
ae216ee
to
cd1b7c1
Compare
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.
/lgtm
PTAL @KPostOffice
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.
One more note
update the docs as well
https://github.com/thoth-station/kebechet/blob/master/docs/managers/version.rst
I have a question: [project]
dynamic = ["version"]
[tool.setuptools-scm]
enabled = true or [project]
dynamic = ["version"]
[tool.setuptools.dynamic]
version = {attr = "thoth.document_sync.__version__"} (I'm not sure it's possible in a general way, but in that case we might want to state that in the docs)
|
/hold |
That is a valid point, we should check/address if the version is not in the project section. |
cd1b7c1
to
78647ce
Compare
96e77a1
to
bc30c61
Compare
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.
/lgtm
PTAL @KPostOffice
An interesting thread about why "version" should never be put in source code and should instead be derived from package metadata when needed. The basic argument here is that version should be set from package metadata, not the other way around. |
I'm not sure what this should mean for this PR, just a rabbit hole that I fell down when looking into Max's concern. One way to just fix the issue raised is to recognize that json if |
I believe we are addressing the required pattern with PR. |
Oh yeah, I see what you mean |
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.
Looks good. Just a few small changes to the new function
project = toml_content.get("project", None) | ||
old_version = project.get("version", None) | ||
try: | ||
new_version = self.get_new_version(old_version) |
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.
Old version must be a string. Passing None
here will throw an error.
if old_version: | ||
toml_content["project"]["version"] = new_version | ||
changed = True | ||
if not changed: |
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.
Having changed
and this conditional will be unnecessary if old_version is checked to not be None
above
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.
Ack
bc30c61
to
738e43b
Compare
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.
Just a couple of small comments and then it should be good I think
toml_content["project"]["version"] = new_version | ||
new_content = toml.dumps(toml_content) | ||
with open(file_path, "w") as output_file: | ||
output_file.write(new_content) |
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.
Here you can directly do toml.dump(toml_content, output_file)
, no need for an intermediate string representation.
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.
done
file_path = os.path.join(root, file_name) | ||
adjusted_version = self.adjust_version_file(file_path) | ||
if file_name in files_dict: | ||
func_to_call: Any = files_dict[file_name] |
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.
could use Callable[[str], Optional[Tuple[str, str]]]
as a type hint here. If it gives any errors, we can just leave it as callable.
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.
Pre commit failed with : error: Incompatible types in assignment (expression has type "Callable[[str], Optional[Tuple[Any, ...]]]", variable has type "Callable[[str], Optional[Tuple[str, str]]]")
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's because of the function signatures of the called functions could be more descriptive too, so you would need to change this line as well as the the function signatures.
738e43b
to
6f2a756
Compare
/test pre-commit |
/retest |
e40cc27
to
9832eb7
Compare
environment_details=ManagerBase.get_environment_details(), | ||
) | ||
) from e | ||
_LOGGER.info("Computed new version: %s", new_version) |
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.
These need to be shifted over so that they are inside the conditional I'm pretty sure.
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.
ack, done
9832eb7
to
f525968
Compare
toml_content["project"]["version"] = new_version | ||
with open(file_path, "w") as output_file: | ||
output_file.write(toml.dumps(toml_content)) | ||
return new_version, old_version |
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.
This also needs to be tabbed over. If there is no version, it should just return 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.
ack
…ager - Update Messages ISSUE_BODY_NO_VERSION_IDENTIFIER_FOUND variable with pyproject.toml related Signed-off-by: Shreekara <sshreeka@redhat.com>
Signed-off-by: Shreekara <sshreeka@redhat.com>
f525968
to
4c2564f
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: KPostOffice The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
/unhold
/lgtm
thanks 👍
Signed-off-by: Shreekara sshreeka@redhat.com
Related Issues and Dependencies
Fixes: #1158
…