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
7a29a5db
Kaydet (Commit)
7a29a5db
authored
Tem 11, 2017
tarafından
Anthony Sottile
Kaydeden (comit)
GitHub
Tem 11, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #4 from asottile/parenthesized_function
Properly detect parens when the function is parenthesized
üst
9ce37f20
5c86831a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
add_trailing_comma.py
add_trailing_comma.py
+6
-3
add_trailing_comma_test.py
tests/add_trailing_comma_test.py
+4
-0
No files found.
add_trailing_comma.py
Dosyayı görüntüle @
7a29a5db
...
@@ -179,13 +179,16 @@ def _fix_call(call, i, tokens):
...
@@ -179,13 +179,16 @@ def _fix_call(call, i, tokens):
#
#
# func_name(arg, arg, arg)
# func_name(arg, arg, arg)
# ^ outer paren
# ^ outer paren
brace_start
,
brace_end
=
'('
,
')'
first_paren
=
None
first_paren
=
None
paren_stack
=
[]
paren_stack
=
[]
for
i
in
range
(
i
,
len
(
tokens
)):
for
i
in
range
(
i
,
len
(
tokens
)):
token
=
tokens
[
i
]
token
=
tokens
[
i
]
if
token
.
src
==
'('
:
if
token
.
src
==
brace_start
:
paren_stack
.
append
(
i
)
paren_stack
.
append
(
i
)
elif
token
.
src
==
')'
:
# the ast lies to us about the beginning of parenthesized functions.
# See #3. (why we make sure there's something to pop here)
elif
token
.
src
==
brace_end
and
paren_stack
:
paren_stack
.
pop
()
paren_stack
.
pop
()
if
(
token
.
line
,
token
.
utf8_byte_offset
)
in
call
.
arg_offsets
:
if
(
token
.
line
,
token
.
utf8_byte_offset
)
in
call
.
arg_offsets
:
...
@@ -194,7 +197,7 @@ def _fix_call(call, i, tokens):
...
@@ -194,7 +197,7 @@ def _fix_call(call, i, tokens):
else
:
else
:
raise
AssertionError
(
'Past end?'
)
raise
AssertionError
(
'Past end?'
)
_fix_inner
(
'('
,
')'
,
first_paren
,
tokens
)
_fix_inner
(
brace_start
,
brace_end
,
first_paren
,
tokens
)
def
_fix_literal
(
literal
,
i
,
tokens
):
def
_fix_literal
(
literal
,
i
,
tokens
):
...
...
tests/add_trailing_comma_test.py
Dosyayı görüntüle @
7a29a5db
...
@@ -42,6 +42,10 @@ xfailif_lt_py35 = pytest.mark.xfail(sys.version_info < (3, 5), reason='py35+')
...
@@ -42,6 +42,10 @@ xfailif_lt_py35 = pytest.mark.xfail(sys.version_info < (3, 5), reason='py35+')
'x((
\n
'
'x((
\n
'
' 1,
\n
'
' 1,
\n
'
'))'
,
'))'
,
# regression test for #3
'(
\n
'
' a
\n
'
').f(b)'
,
),
),
)
)
def
test_fix_calls_noops
(
src
):
def
test_fix_calls_noops
(
src
):
...
...
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