question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pre-commit removes `# -*- coding: utf-8 -*-` pragma

See original GitHub issue

Hello,

My CICD is running pre-commit run And it wants to remove the first line of percent file generate with jupytext --to py notebook.ipynb --set-formats "ipynb,py:percent"

The first line is: # -*- coding: utf-8 -*-

Related to the following hook: https://github.com/pre-commit/pre-commit-hooks/blob/master/pre_commit_hooks/fix_encoding_pragma.py

I would like to know what is the best way to handle this issue? Remove the line? Add some setting in pre-commit or jupytext?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mwoutscommented, Feb 9, 2022

Oh that’s interesting - maybe it’s time to remove this - I’ll give it a try and keep you posted.

0reactions
stephanecollotcommented, Feb 9, 2022

I just look into the code and I saw: https://github.com/mwouts/jupytext/blob/cbfe2ff9e06610f2ddefd4d98646a551c25fba86/jupytext/header.py#L63-L67

I just tried now with an empty notebook, and it works, no first encoding line added. So It means have some non ascii characters in the notebook I was facing the issue with.

Sorry!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Supported hooks - pre-commit
pycln - A formatter for finding and removing unused import statements. github.com/nbQA-dev/nbQA. nbqa - Run any standard Python code quality tool on a...
Read more >
pre-commit-hooks - Git at Google
Add # -*- coding: utf-8 -*- to the top of python files. To remove the coding pragma pass --remove (useful in a python3-only...
Read more >
.pre-commit-config.yaml · TencentARC/GFPGANv1 at main
... and remove incorrect entry for pkg-resources==0.0.0 - id: fix-encoding-pragma # Remove the coding pragma: # -*- coding: utf-8 -*- args: ["--remove"] ...
Read more >
.pre-commit-config.yaml · master · Zihao Wei / A-ESRGAN · GitLab
id: fix-encoding-pragma # Remove the coding pragma: # -*- coding: utf-8 -*-. 44. args: ["--remove"]. 45. - id: mixed-line-ending # Replace or check...
Read more >
Pre-commit Pylint "exit code: 32" upon committing, no issues ...
The issue was caused by #"--ignore-long-lines", # Ignores long lines. in the .pre-commit-config.yaml . I assume it conflicts with the line ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found