-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
pre-commit command ran for humitos/log/sentry branch #3898
Conversation
Log only what we need as ERROR when it's something that we need/want to take a look that something could be a bug/issue. There are some ERROR that were replaced by WARNING since they are some failures but that we don't need to take a look and the message shown to the user should be enough for them.
2e89010
to
b90552b
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.
This is bigger than I thought, I have to come back to this.
I left off at environment.py, here are a few changes so far.
readthedocs/builds/syncers.py
Outdated
slash=slash, | ||
user=sync_user, | ||
server=server, | ||
path=path, slash=slash, user=sync_user, server=server, |
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 squashed the continuation
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.
I had sent a comment here, but my internet connection didn't help me:
By adding a ,
after the target
here, we get a one attribute per line formatting automatically by yapf.
There are many changes on these files were we can apply this fix to get the more readable way, but I don't want to do it manually for now.
I think we can easily add the trailing comman once we start using pre-commit in a daily basis.
Anyway, I think we can use this PR to discuss/tweak yapf a little more.
There are things that need manual work. Although, for this particular issue that the trailling comma is missing we could add automatically before calling yapf with this hook: https://github.com/asottile/add-trailing-comma
readthedocs/builds/syncers.py
Outdated
path=path, | ||
user=sync_user, | ||
server=server, | ||
host=host, path=path, user=sync_user, server=server, |
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.
Squashed continuation here
queryset = ( | ||
Build.objects.values('project', | ||
'version').annotate(max_date=Max('date')) | ||
.filter(max_date__lt=max_date).order_by('-max_date')) |
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.
Previous continuation style was better
readthedocs/core/views/hooks.py
Outdated
data = json.loads(request.POST.get('payload')) | ||
else: | ||
data = json.loads(request.body) | ||
http_url = data['repository']['url'] | ||
http_search_url = http_url.replace('http://', '').replace('https://', '') | ||
http_search_url = http_url.replace('http://', | ||
'').replace('https://', '') |
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.
I'd prefer a different method of breaking this up to multiple lines
I re-configure I found one problem though, the definition of the functions is also affected by Anyway, it seems to be too much closer to what you want. |
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.
I'd say that this is very close to what we want.
I noted some points that we should care
docroot, | ||
filename, | ||
source_suffix='.rst', | ||
action='view', |
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, the function is affected by add-trailing-comma
plugin.
I want to check how to disable this case.
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 is not a problem of this plugin, but a combination of add-trailing-comma
plus yapf
.
When this is detected
def myfunc(
a, b, c, d, e, f, argument, larger, here, to, reach, eighty, lines, NOW
):
trailing comma adds a comma in the end, and yapf format it on an argument per line in the next pass.
sync_repository.apply_async( | ||
args=(version.pk,), | ||
) | ||
sync_repository.apply_async(args=(version.pk,),) |
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.
It seems it gets confused here. Not a big issue, though.
@@ -173,12 +182,16 @@ def github_build(request): # noqa: D205 | |||
""" | |||
if request.method == 'POST': | |||
try: | |||
if request.META['CONTENT_TYPE'] == 'application/x-www-form-urlencoded': | |||
if request.META['CONTENT_TYPE' | |||
] == 'application/x-www-form-urlencoded': |
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 is one is terrible.
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.
We could add # yapf: disable
here, since it's a special case.
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.
or use a variable for application/x-www...
so the line is shorter
version = 2 if request.META.get('HTTP_USER_AGENT') == 'Bitbucket-Webhooks/2.0' else 1 | ||
version = 2 if request.META.get( | ||
'HTTP_USER_AGENT', | ||
) == 'Bitbucket-Webhooks/2.0' else 1 |
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 one is also terrible.
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.
There are some _PENALTY
settings that we should take a look for this case.
'is_cc_group': True, | ||
'fields': [] | ||
} | ||
group = {'is_cc_group': True, 'fields': []} |
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 it should have added the ,
and formatted it as it was.
if filename in [ | ||
'search.fjson', | ||
'genindex.fjson', | ||
'py-modindex.fjson', ]: |
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.
Also weird here
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.
I'd say that this is very close to what we want.
I noted some points that we should care
This is not possible to disable in this plugin. I opened an issue in yapf to see why it's not respecting a setting: google/yapf#551 |
Pretty sure we can close this, as it has a million conflicts. |
Actually not sure -- what should we do here? |
Let's close it. We still don't have a strict policy regarding how to ues We can come back to this later with more time. |
Logic changes are under #3893