FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-mode/pymode/__init__.py at develop · python-mode/python-mode · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python-mode
/
python-mode
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
758
Star
5.5k
Code
Issues
38
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-mode
/
pymode
/
__init__.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (47 loc) · 1.91 KB
Breadcrumbs
python-mode
/
pymode
/
__init__.py
Copy path
File metadata and controls
64 lines (47 loc) · 1.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""Pymode support functions."""
import
sys
from
importlib
.
machinery
import
PathFinder
as
_PathFinder
import
vim
# noqa
if
not
hasattr
(
vim
,
'find_module'
):
try
:
vim
.
find_module
=
_PathFinder
.
find_module
# deprecated
except
AttributeError
:
def
_find_module
(
package_name
):
spec
=
_PathFinder
.
find_spec
(
package_name
)
return
spec
.
loader
if
spec
else
None
vim
.
find_module
=
_find_module
def
auto
():
"""Fix PEP8 errors in current buffer using ruff format.
pymode: uses it in command PymodeLintAuto with pymode#lint#auto()
"""
from
.
ruff_integration
import
run_ruff_format
,
check_ruff_available
if
not
check_ruff_available
():
vim
.
command
(
'echoerr "Ruff is not available. Please install ruff: pip install ruff"'
)
return
current_buffer
=
vim
.
current
.
buffer
file_path
=
current_buffer
.
name
if
not
file_path
:
vim
.
command
(
'echoerr "Cannot format unsaved buffer"'
)
return
# Get current buffer content
content
=
'
\n
'
.
join
(
current_buffer
)
+
'
\n
'
# Run ruff format
formatted_content
=
run_ruff_format
(
file_path
,
content
)
if
formatted_content
is
not
None
and
formatted_content
!=
content
:
# Update buffer with formatted content
lines
=
formatted_content
.
rstrip
(
'
\n
'
).
splitlines
()
if
not
lines
:
lines
=
[
''
]
current_buffer
[:]
=
lines
# Mark buffer as modified so Vim knows it can be written
vim
.
command
(
'setlocal modified'
)
vim
.
command
(
'echom "Ruff format completed"'
)
else
:
vim
.
command
(
'echom "No formatting changes needed"'
)
def
get_documentation
():
"""Search documentation and append to current buffer."""
from
io
import
StringIO
sys
.
stdout
,
_
=
StringIO
(),
sys
.
stdout
help
(
vim
.
eval
(
'a:word'
))
sys
.
stdout
,
out
=
_
,
sys
.
stdout
.
getvalue
()
vim
.
current
.
buffer
.
append
(
str
(
out
).
splitlines
(),
0
)
Back
|
FazBrowse Home
|
New Git URL