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

pre-commit command ran for humitos/log/sentry branch #3898

Closed
wants to merge 5 commits into from

Conversation

humitos
Copy link
Member

@humitos humitos commented Apr 4, 2018

Logic changes are under #3893

humitos added 3 commits April 2, 2018 22:24
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.
@humitos humitos mentioned this pull request Apr 4, 2018
@humitos humitos force-pushed the humitos/auto-lint/sentry branch from 2e89010 to b90552b Compare April 4, 2018 03:26
@humitos humitos requested a review from agjohnson April 5, 2018 22:04
@agjohnson agjohnson changed the base branch from humitos/log/sentry to master April 5, 2018 22:58
Copy link
Contributor

@agjohnson agjohnson left a 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.

slash=slash,
user=sync_user,
server=server,
path=path, slash=slash, user=sync_user, server=server,
Copy link
Contributor

Choose a reason for hiding this comment

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

This squashed the continuation

Copy link
Member Author

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

path=path,
user=sync_user,
server=server,
host=host, path=path, user=sync_user, server=server,
Copy link
Contributor

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'))
Copy link
Contributor

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

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://', '')
Copy link
Contributor

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

@humitos
Copy link
Member Author

humitos commented Apr 6, 2018

I re-configure pre-commit (depends on this branch readthedocs/common#2) and re-run it to show what are the news here.

I found one problem though, the definition of the functions is also affected by add-trailing-comma plugin, so I will see if we can disable that.

Anyway, it seems to be too much closer to what you want.

Copy link
Member Author

@humitos humitos left a 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',
Copy link
Member Author

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.

Copy link
Member Author

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,),)
Copy link
Member Author

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':
Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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
Copy link
Member Author

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.

Copy link
Member Author

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': []}
Copy link
Member Author

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', ]:
Copy link
Member Author

Choose a reason for hiding this comment

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

Also weird here

Copy link
Member Author

@humitos humitos left a 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

@humitos
Copy link
Member Author

humitos commented Apr 7, 2018

I found one problem though, the definition of the functions is also affected by add-trailing-comma plugin, so I will see if we can disable that.

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

@agjohnson agjohnson added this to the Cleanup milestone Apr 17, 2018
@ericholscher
Copy link
Member

Pretty sure we can close this, as it has a million conflicts.

@ericholscher
Copy link
Member

Actually not sure -- what should we do here?

@humitos
Copy link
Member Author

humitos commented May 30, 2018

Let's close it.

We still don't have a strict policy regarding how to ues pre-commit. We are not forcing nobody to run this command and because nobody is using it in a daily basis it may need some more work now.

We can come back to this later with more time.

@humitos humitos closed this May 30, 2018
@humitos humitos deleted the humitos/auto-lint/sentry branch May 30, 2018 21:20
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.

4 participants