Comments (5)
I suppose the other facet is if the file needs to be rewritten, does it get rewritten with the BOM if it had one before? (I also noticed that DOS files get re-written as UNIX files, which is a separate issue...)
from absolufy-imports.
Hi @mwtoews
Thanks for your report - do you want to submit a pull request to fix this?
from absolufy-imports.
I'll take a look...
from absolufy-imports.
I think something like this
with open(file, 'rb') as fb:
contents_bytes = fb.read()
try:
contents_text = contents_bytes.decode()
except UnicodeDecodeError:
print(f'{file} is non-utf-8 (not supported)')
return 1
tree = ast.parse(contents_text)
should be enough. I'll try to get something out today, there's another issue to fix
from absolufy-imports.
I have something similar, but I'm also looking at line breaks too ...
from absolufy-imports.
Related Issues (9)
- --keep-relative-imports in __init__.py files only HOT 4
- Provide directory or package as input HOT 2
- Packages and Python built-in imports are not supported when the project has somewhere a folder with the same name HOT 7
- FR: support usage without pre-commit HOT 1
- Define an authorized level of relativity HOT 1
- Add option to just "absolufy" level-up imports HOT 1
- It doesn't work on the cuda-python repo HOT 3
- BUG from .import mymodule doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from absolufy-imports.