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
145402a0
Kaydet (Commit)
145402a0
authored
Şub 07, 2019
tarafından
Anthony Sottile
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
python 3.8 fixes
üst
eef2b744
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
.travis.yml
.travis.yml
+4
-1
add_trailing_comma.py
add_trailing_comma.py
+9
-7
No files found.
.travis.yml
Dosyayı görüntüle @
145402a0
dist
:
xenial
language
:
python
matrix
:
include
:
...
...
@@ -7,7 +8,9 @@ matrix:
-
env
:
TOXENV=py36
python
:
3.6
-
env
:
TOXENV=pypy
python
:
pypy-5.7.1
python
:
pypy2.7-5.10.0
-
env
:
TOXENV=py38
python
:
3.8-dev
install
:
pip install coveralls tox
script
:
tox
after_success
:
coveralls
...
...
add_trailing_comma.py
Dosyayı görüntüle @
145402a0
...
...
@@ -18,8 +18,7 @@ from tokenize_rt import UNIMPORTANT_WS
Call
=
collections
.
namedtuple
(
'Call'
,
(
'node'
,
'star_args'
,
'arg_offsets'
))
Func
=
collections
.
namedtuple
(
'Func'
,
(
'node'
,
'star_args'
,
'arg_offsets'
))
Class
=
collections
.
namedtuple
(
'Class'
,
(
'node'
,
'star_args'
,
'arg_offsets'
))
Literal
=
collections
.
namedtuple
(
'Literal'
,
(
'node'
,
'backtrack'
))
Literal
.
__new__
.
__defaults__
=
(
False
,)
Literal
=
collections
.
namedtuple
(
'Literal'
,
(
'node'
,))
Fix
=
collections
.
namedtuple
(
'Fix'
,
(
'braces'
,
'multi_arg'
,
'initial_indent'
))
NEWLINES
=
frozenset
((
ESCAPED_NL
,
'NEWLINE'
,
'NL'
))
...
...
@@ -80,8 +79,11 @@ class FindNodes(ast.NodeVisitor):
def
visit_Tuple
(
self
,
node
):
if
node
.
elts
:
# tuples lie about offset -- tell the later machinery to backtrack
self
.
tuples
[
_to_offset
(
node
)]
=
Literal
(
node
,
backtrack
=
True
)
# in < py38 tuples lie about offset -- later we must backtrack
if
sys
.
version_info
<
(
3
,
8
):
# pragma: no cover (<py38)
self
.
tuples
[
_to_offset
(
node
)]
=
Literal
(
node
)
else
:
# pragma: no cover (py38+)
self
.
literals
[
_to_offset
(
node
)]
=
Literal
(
node
)
self
.
generic_visit
(
node
)
def
visit_Call
(
self
,
node
):
...
...
@@ -234,7 +236,7 @@ def _find_call(call, i, tokens):
return
_find_simple
(
first_brace
,
tokens
)
def
_find_tuple
(
i
,
tokens
):
def
_find_tuple
(
i
,
tokens
):
# pragma: no cover (<py38)
# tuples are evil, we need to backtrack to find the opening paren
i
-=
1
while
tokens
[
i
]
.
name
in
NON_CODING_TOKENS
:
...
...
@@ -376,7 +378,7 @@ def _fix_src(contents_text, py35_plus, py36_plus):
# classes can be treated as calls
cls
=
visitor
.
classes
[
token
.
offset
]
fixes
.
append
((
True
,
_find_call
(
cls
,
i
,
tokens
)))
elif
token
.
offset
in
visitor
.
literals
:
elif
token
.
offset
in
visitor
.
literals
and
token
.
src
in
START_BRACES
:
fixes
.
append
((
True
,
_find_simple
(
i
,
tokens
)))
elif
token
.
offset
in
visitor
.
imports
:
# some imports do not have parens
...
...
@@ -394,7 +396,7 @@ def _fix_src(contents_text, py35_plus, py36_plus):
# need to handle tuples afterwards as tuples report their starting
# starting index as the first element, which may be one of the above
# things.
if
token
.
offset
in
visitor
.
tuples
:
if
token
.
offset
in
visitor
.
tuples
:
# pragma: no cover (<py38)
fix_data
=
_find_tuple
(
i
,
tokens
)
if
fix_data
is
not
None
:
_fix_brace
(
fix_data
,
True
,
tokens
)
...
...
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