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

insert_license - write file back in original encoding #39

Closed
mdeweerd opened this issue May 23, 2022 · 3 comments
Closed

insert_license - write file back in original encoding #39

mdeweerd opened this issue May 23, 2022 · 3 comments

Comments

@mdeweerd
Copy link
Contributor

In insert_license.py we can red:

    for encoding in ('utf8', 'ISO-8859-1'):  # we could use the chardet library to support more encodings

But when writeing the file back, utf8 is used, so the original file encoding could be changed.

It would be better to remember the original encoding to reuse it on writeback.

@Lucas-C
Copy link
Owner

Lucas-C commented Jul 3, 2022

Agreed, that would be better.

Have you faced a case where the wrong encoding was used on writeback?
I guess this line makes it very likely to happen:
https://github.com/Lucas-C/pre-commit-hooks/blob/v1.2.0/pre_commit_hooks/insert_license.py#L233

@mdeweerd
Copy link
Contributor Author

mdeweerd commented Jul 3, 2022

Yes, I was faced with that.

@Lucas-C
Copy link
Owner

Lucas-C commented Jul 3, 2022

I submitted #44 in order to implement this

@Lucas-C Lucas-C closed this as completed in 2c25474 Jul 3, 2022
Lucas-C added a commit that referenced this issue Jul 3, 2022
Re-using input file encoding for writeback - close #39
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

No branches or pull requests

2 participants