Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
A
add-trailing-comma
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
add-trailing-comma
Commits
763da6fa
Kaydet (Commit)
763da6fa
authored
Tem 15, 2017
tarafından
Anthony Sottile
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Simplify functions now that we are handling unhug of (
üst
a9b3be1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
21 deletions
+9
-21
add_trailing_comma.py
add_trailing_comma.py
+9
-21
No files found.
add_trailing_comma.py
Dosyayı görüntüle @
763da6fa
...
...
@@ -16,7 +16,7 @@ from tokenize_rt import UNIMPORTANT_WS
Offset
=
collections
.
namedtuple
(
'Offset'
,
(
'line'
,
'utf8_byte_offset'
))
Call
=
collections
.
namedtuple
(
'Call'
,
(
'node'
,
'star_args'
,
'arg_offsets'
))
Func
=
collections
.
namedtuple
(
'Func'
,
(
'node'
,
'
star_args'
,
'
arg_offsets'
))
Func
=
collections
.
namedtuple
(
'Func'
,
(
'node'
,
'arg_offsets'
))
Literal
=
collections
.
namedtuple
(
'Literal'
,
(
'node'
,
'backtrack'
))
Literal
.
__new__
.
__defaults__
=
(
False
,)
Fix
=
collections
.
namedtuple
(
'Fix'
,
(
'braces'
,
'multi_arg'
,
'initial_indent'
))
...
...
@@ -138,34 +138,24 @@ class FindNodes(ast.NodeVisitor):
self
.
generic_visit
(
node
)
def
visit_FunctionDef
(
self
,
node
):
has_starargs
=
False
args
=
list
(
node
.
args
.
args
)
if
node
.
args
.
vararg
:
if
isinstance
(
node
.
args
.
vararg
,
ast
.
AST
):
# pragma: no cover (py3)
args
.
append
(
node
.
args
.
vararg
)
has_starargs
=
True
if
node
.
args
.
kwarg
:
if
isinstance
(
node
.
args
.
kwarg
,
ast
.
AST
):
# pragma: no cover (py3)
args
.
append
(
node
.
args
.
kwarg
)
has_starargs
=
True
py3_kwonlyargs
=
getattr
(
node
.
args
,
'kwonlyargs'
,
None
)
if
py3_kwonlyargs
:
# pragma: no cover (py3)
args
.
extend
(
py3_kwonlyargs
)
has_starargs
=
True
has_starargs
=
(
node
.
args
.
vararg
or
node
.
args
.
kwarg
or
# python 3 only
getattr
(
node
.
args
,
'kwonlyargs'
,
None
)
)
orig
=
node
.
lineno
is_multiline
=
False
offsets
=
set
()
for
argnode
in
args
:
for
argnode
in
node
.
args
.
args
:
offset
=
_to_offset
(
argnode
)
if
offset
.
line
>
orig
:
is_multiline
=
True
offsets
.
add
(
offset
)
if
is_multiline
:
if
is_multiline
and
not
has_starargs
:
key
=
Offset
(
node
.
lineno
,
node
.
col_offset
)
self
.
funcs
[
key
]
=
Func
(
node
,
has_starargs
,
offsets
)
self
.
funcs
[
key
]
=
Func
(
node
,
offsets
)
self
.
generic_visit
(
node
)
...
...
@@ -359,8 +349,6 @@ def _fix_src(contents_text, py35_plus):
fix_data
=
_find_call
(
call
,
i
,
tokens
)
elif
key
in
visitor
.
funcs
:
func
=
visitor
.
funcs
[
key
]
# any amount of starargs excludes adding a comma for defs
add_comma
=
not
func
.
star_args
# functions can be treated as calls
fix_data
=
_find_call
(
func
,
i
,
tokens
)
# Handle parenthesized things
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment