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

fix file preambles for Python scripts #357

Merged
merged 3 commits into from
Oct 14, 2019
Merged

fix file preambles for Python scripts #357

merged 3 commits into from
Oct 14, 2019

Conversation

mpenkov
Copy link
Collaborator

@mpenkov mpenkov commented Oct 1, 2019

This follows on from comments on piskvorky/gensim#2610 (comment)

Main points:

  • Added author (not sure how necessary this is, git blame will list everyone who has ever touched the file)
  • Removed shebangs for non-executable files

I mostly copied the header from smart_open/__init__.py. Let me know if you want me to change anything (I've got a script that takes care of it, so it's not a problem).

Once you're happy, I can let this script loose on the gensim repo.

@mpenkov mpenkov requested a review from piskvorky October 1, 2019 05:46
Copy link
Owner

@piskvorky piskvorky left a comment

Choose a reason for hiding this comment

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

Good idea to automate this. Are there any instances where automation could hurt? Especially in Gensim.

In other words, is the rule "if a file ends in .py, slap on this uniform header", or is the logic more complicated?

#
# This code is distributed under the terms and conditions
# from the MIT License (MIT).
#
Copy link
Owner

Choose a reason for hiding this comment

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

Blank line instead of blank comment, to separate the blocks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's better to keep the entire preamble as a single comment.

If you use blank lines to separate comment blanks, identifying preambles in files (for scripting, etc.) becomes more difficult.

Copy link
Owner

@piskvorky piskvorky Oct 9, 2019

Choose a reason for hiding this comment

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

It does not separate comment blocks – it separates preamble from actual code (imports).

@@ -1,3 +1,13 @@
#
# -*- coding: utf-8 -*-
Copy link
Owner

@piskvorky piskvorky Oct 1, 2019

Choose a reason for hiding this comment

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

The leading blank comment on top looks a bit weird, but I looked it up and coding can indeed be on the first or second line, so I guess this is fine: PEP263

I'd prefer to include the Python shebang always (any harm?).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can get rid of the leading blank line. It's not necessary.

Personally, I avoid the shebang unless the script is executable, simply because it is unnecessary otherwise.

I'd prefer to include the Python shebang always (any harm?).

Well, there's no harm (other than it being an eyesore). But consider this analogy: there's no harm in making all of our modules executable (chmod u+x), but we don't do it for the same reason (lack of necessity).

smart_open/webhdfs.py Outdated Show resolved Hide resolved
@mpenkov
Copy link
Collaborator Author

mpenkov commented Oct 9, 2019

@piskvorky For the actual logic, see the release/check_preamble.py file.

It's trivial. I think we can use it on gensim as-is.

@menshikh-iv WDYT?

@menshikh-iv
Copy link
Contributor

@mpenkov why not? Though I still don't understand, why copyright needed in each file.

@mpenkov
Copy link
Collaborator Author

mpenkov commented Oct 9, 2019

@piskvorky Is there a reason to even include a preamble in each file? We already have a separate license file.

@piskvorky
Copy link
Owner

piskvorky commented Oct 9, 2019

People copy around files, without necessarily copying entire projects. Not a big deal, just best practice.

@mpenkov mpenkov merged commit 6b0e062 into piskvorky:master Oct 14, 2019
@mpenkov mpenkov deleted the preamble branch October 14, 2019 08:47
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