-
Notifications
You must be signed in to change notification settings - Fork 105
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
extend linter API to allow overriding the max line length #51
Conversation
if args.linelength != code_width: | ||
# generate temporary config file with custom line length | ||
temp_config = tempfile.NamedTemporaryFile('w') | ||
temp_config.write(config_str + '\ncode_width=%d' % args.linelength) |
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 appends the config parameter, but does not remove the original if it's already set. Will that work correctly in that 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.
Yes, in an ini-like file the last value is the one being used.
+1 |
code_width = int(re.split('[ \t#]', code_width, maxsplit=1)[0]) | ||
if args.linelength != code_width: | ||
# generate temporary config file with custom line length | ||
temp_config = tempfile.NamedTemporaryFile('w') |
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.
https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile
Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later).
Fixed in #52.
Code generators can't always ensure that the generated code stays within a specific maximum line length. So using this that setting can be overridden.