@@ -30,11 +30,11 @@ def is_wrong_name(name: str, to_check: Iterable[str]) -> bool:
3030
3131 """
3232 for name_to_check in to_check :
33- choices_to_check = [
33+ choices_to_check = {
3434 name_to_check ,
3535 '_{0}' .format (name_to_check ),
3636 '{0}_' .format (name_to_check ),
37- ]
37+ }
3838 if name in choices_to_check :
3939 return True
4040 return False
@@ -74,7 +74,7 @@ def is_too_short_name(
7474 min_length : int = defaults .MIN_NAME_LENGTH ,
7575) -> bool :
7676 """
77- Checks for too short variable names.
77+ Checks for too short names.
7878
7979 >>> is_too_short_name('test')
8080 False
@@ -100,7 +100,7 @@ def is_too_long_name(
100100 max_length : int = defaults .MAX_NAME_LENGTH ,
101101) -> bool :
102102 """
103- Checks for too long variable names.
103+ Checks for too long names.
104104
105105 >>> is_too_long_name('test')
106106 False
@@ -123,7 +123,7 @@ def is_too_long_name(
123123
124124def does_contain_underscored_number (name : str ) -> bool :
125125 """
126- Checks for variable names with underscored number.
126+ Checks for names with underscored number.
127127
128128 >>> does_contain_underscored_number('star_wars_episode2')
129129 False
@@ -158,7 +158,7 @@ def does_contain_underscored_number(name: str) -> bool:
158158
159159def does_contain_consecutive_underscores (name : str ) -> bool :
160160 """
161- Checks if variable contains consecutive underscores in middle of name.
161+ Checks if name contains consecutive underscores in middle of name.
162162
163163 >>> does_contain_consecutive_underscores('name')
164164 False
@@ -186,3 +186,28 @@ def does_contain_consecutive_underscores(name: str) -> bool:
186186 return True
187187
188188 return False
189+
190+
191+ def does_contain_unicode (name : str ) -> bool :
192+ """
193+ Check if name contains unicode characters.
194+
195+ >>> does_contain_unicode('hello_world1')
196+ False
197+
198+ >>> does_contain_unicode('')
199+ False
200+
201+ >>> does_contain_unicode('привет_мир1')
202+ True
203+
204+ >>> does_contain_unicode('russian_техт')
205+ True
206+
207+ """
208+ try :
209+ name .encode ('ascii' )
210+ except UnicodeEncodeError :
211+ return True
212+ else :
213+ return False
0 commit comments