Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
04fd783c
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "59cd9de39da4c406e12c1785f70ee73806ebc6ba"
Unverified
Commit
04fd783c
authored
Feb 08, 2021
by
Sylvain Gugger
Committed by
GitHub
Feb 08, 2021
Browse files
Check copies match full class/function names (#10030)
parent
d51302cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
utils/check_copies.py
utils/check_copies.py
+5
-2
No files found.
utils/check_copies.py
View file @
04fd783c
...
@@ -36,7 +36,8 @@ def find_code_in_transformers(object_name):
...
@@ -36,7 +36,8 @@ def find_code_in_transformers(object_name):
module
=
parts
[
i
]
module
=
parts
[
i
]
while
i
<
len
(
parts
)
and
not
os
.
path
.
isfile
(
os
.
path
.
join
(
TRANSFORMERS_PATH
,
f
"
{
module
}
.py"
)):
while
i
<
len
(
parts
)
and
not
os
.
path
.
isfile
(
os
.
path
.
join
(
TRANSFORMERS_PATH
,
f
"
{
module
}
.py"
)):
i
+=
1
i
+=
1
module
=
os
.
path
.
join
(
module
,
parts
[
i
])
if
i
<
len
(
parts
):
module
=
os
.
path
.
join
(
module
,
parts
[
i
])
if
i
>=
len
(
parts
):
if
i
>=
len
(
parts
):
raise
ValueError
(
raise
ValueError
(
f
"`object_name` should begin with the name of a module of transformers but got
{
object_name
}
."
f
"`object_name` should begin with the name of a module of transformers but got
{
object_name
}
."
...
@@ -49,7 +50,9 @@ def find_code_in_transformers(object_name):
...
@@ -49,7 +50,9 @@ def find_code_in_transformers(object_name):
indent
=
""
indent
=
""
line_index
=
0
line_index
=
0
for
name
in
parts
[
i
+
1
:]:
for
name
in
parts
[
i
+
1
:]:
while
line_index
<
len
(
lines
)
and
re
.
search
(
fr
"^
{
indent
}
(class|def)\s+
{
name
}
"
,
lines
[
line_index
])
is
None
:
while
(
line_index
<
len
(
lines
)
and
re
.
search
(
fr
"^
{
indent
}
(class|def)\s+
{
name
}
(\(|\:)"
,
lines
[
line_index
])
is
None
):
line_index
+=
1
line_index
+=
1
indent
+=
" "
indent
+=
" "
line_index
+=
1
line_index
+=
1
...
...
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