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

Sourcery Starbot ⭐ refactored sryabkov/kube-janitor #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SourceryAI
Copy link

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch https://github.com/sourcery-ai-bot/kube-janitor master
git merge --ff-only FETCH_HEAD
git reset HEAD^

api = pykube.HTTPClient(config)
return api
return pykube.HTTPClient(config)
Copy link
Author

Choose a reason for hiding this comment

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

Function get_kube_api refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)

Comment on lines -112 to +139
now = utcnow()
timestamp = now.strftime("%Y-%m-%dT%H:%M:%SZ")
event = Event(
resource.api,
{
"metadata": {
"namespace": resource.namespace,
"generateName": "kube-janitor-",
},
"type": "Normal",
"count": 1,
"firstTimestamp": timestamp,
"lastTimestamp": timestamp,
"reason": reason,
"involvedObject": {
"apiVersion": resource.version,
"name": resource.name,
"namespace": resource.namespace,
"kind": resource.kind,
"resourceVersion": resource.metadata.get("resourceVersion"),
# https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
"uid": resource.metadata.get("uid"),
},
"message": message,
"source": {"component": "kube-janitor"},
},
)
if not dry_run:
now = utcnow()
timestamp = now.strftime("%Y-%m-%dT%H:%M:%SZ")
event = Event(
resource.api,
{
"metadata": {
"namespace": resource.namespace,
"generateName": "kube-janitor-",
},
"type": "Normal",
"count": 1,
"firstTimestamp": timestamp,
"lastTimestamp": timestamp,
"reason": reason,
"involvedObject": {
"apiVersion": resource.version,
"name": resource.name,
"namespace": resource.namespace,
"kind": resource.kind,
"resourceVersion": resource.metadata.get("resourceVersion"),
# https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
"uid": resource.metadata.get("uid"),
},
"message": message,
"source": {"component": "kube-janitor"},
},
)
Copy link
Author

Choose a reason for hiding this comment

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

Function create_event refactored with the following changes:

  • Move assignments closer to their usage (move-assign)

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.

1 participant