Skip to content

More type fixes #590

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

Merged
merged 10 commits into from
May 14, 2024
Merged

More type fixes #590

merged 10 commits into from
May 14, 2024

Conversation

wch
Copy link
Collaborator

@wch wch commented May 13, 2024

This PR makes more typing fixes.

NOTE: This PR also removes use of the deprecated function datetime.datetime.utcnow(). This will result in a behavior change in logging in one place, where instead of writing 2024-05-13 17:03:09.857000, it will write 2024-05-13 17:03:09.857000+00:00. If this is undesirable, I can get it to format the string without the +00:00.

Copy link

github-actions bot commented May 13, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
4757 3544 75% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/init.py 50% 🟢
rsconnect/actions.py 41% 🟢
rsconnect/api.py 71% 🟢
rsconnect/environment.py 84% 🟢
rsconnect/main.py 61% 🟢
rsconnect/metadata.py 91% 🟢
TOTAL 66% 🟢

updated for commit: 2290258 by action🐍

@@ -1347,7 +1347,7 @@ def _tweak_response(self, response: HTTPResponse) -> JsonData | HTTPResponse:
def get_extra_headers(self, url: str, method: str, body: str | bytes):
canonical_request_method = method.upper()
canonical_request_path = parse.urlparse(url).path
canonical_request_date = datetime.datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
canonical_request_date = datetime.datetime.now(datetime.timezone.utc).strftime("%a, %d %b %Y %H:%M:%S GMT")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that this change will not result in changed output, because strftime() is being called with a format string.

@@ -169,7 +169,10 @@ def pip_freeze():
pip_stdout = filter_pip_freeze_output(pip_stdout)

pip_stdout = (
"# requirements.txt generated by rsconnect-python on " + str(datetime.datetime.utcnow()) + "\n" + pip_stdout
"# requirements.txt generated by rsconnect-python on "
+ str(datetime.datetime.now(datetime.timezone.utc))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will result in +00:00 being added to the output.

@@ -721,7 +731,7 @@ def update_content_item_last_build_time(self, guid: str, defer_save: bool = Fals
"""
with self._lock:
content = self.get_content_item(guid)
content["rsconnect_last_build_time"] = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
content["rsconnect_last_build_time"] = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that this change will not result in changed output, because strftime() is being called with a format string.

@@ -16,6 +16,7 @@
import typing
import webbrowser
from os.path import abspath, dirname
from ssl import SSLError
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@wch wch requested a review from mmarchetti May 14, 2024 06:01
@wch wch marked this pull request as ready for review May 14, 2024 06:01
@wch
Copy link
Collaborator Author

wch commented May 14, 2024

The GitHub Actions workflows don't seem to be running on the latest commit. Any idea why? (It won't let me merge until they run.)

@nealrichardson
Copy link
Contributor

The GitHub Actions workflows don't seem to be running on the latest commit. Any idea why? (It won't let me merge until they run.)

It's because I renamed the default branch to main, but the workflow only is triggered on master. Sorry. Do you want to fix that here or want me to make a separate patch for that?

@nealrichardson
Copy link
Contributor

Ironically, the workflow is called main 😂 https://github.com/posit-dev/rsconnect-python/blob/main/.github/workflows/main.yml#L4-L9

@wch
Copy link
Collaborator Author

wch commented May 14, 2024

Ah thanks, I can fix it here.

@wch wch merged commit e8e771f into main May 14, 2024
@wch wch deleted the type-fixes branch May 14, 2024 16:43
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.

3 participants