uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
004d2c8024e042fadad2bf22
train
function
def main(): with patch.object(jstest, 'prepare_controllers', prepare_controllers): jstest.main()
def main():
with patch.object(jstest, 'prepare_controllers', prepare_controllers): jstest.main()
prepare_controllers for running widget js tests instead of notebook js tests """ if options.testgroups: groups = options.testgroups else: groups = [''] return [ WidgetTestController(g, extra_args=options.extra_args) for g in groups ], [] def main():
63
64
24
3
60
wangyum/anaconda
pkgs/ipywidgets-4.1.1-py27_0/lib/python2.7/site-packages/ipywidgets/jstest.py
Python
main
main
52
54
52
52
65e6f5de829e8524c7642c53d5e78b87474b2eae
bigcode/the-stack
train
ab980fca6082cb7b9de82fab
train
class
class WidgetTestController(jstest.JSController): """Javascript test subclass that installs widget nbextension in test environment""" def __init__(self, section, *args, **kwargs): extra_args = kwargs.pop('extra_args', None) super(WidgetTestController, self).__init__(section, *args, **kwargs) ...
class WidgetTestController(jstest.JSController):
"""Javascript test subclass that installs widget nbextension in test environment""" def __init__(self, section, *args, **kwargs): extra_args = kwargs.pop('extra_args', None) super(WidgetTestController, self).__init__(section, *args, **kwargs) test_cases = os.path.join(here, 'tes...
terms of the Modified BSD License. import os try: from unittest.mock import patch except ImportError: from mock import patch # py2 from notebook import jstest from ipywidgets.install import install here = os.path.dirname(__file__) class WidgetTestController(jstest.JSController):
64
64
169
10
54
wangyum/anaconda
pkgs/ipywidgets-4.1.1-py27_0/lib/python2.7/site-packages/ipywidgets/jstest.py
Python
WidgetTestController
WidgetTestController
22
37
22
22
7f894ded0af6d8a69ba271e6d4edda7411b0670a
bigcode/the-stack
train
63ffecb8ee918511be423a5d
train
function
def prepare_controllers(options): """Monkeypatched prepare_controllers for running widget js tests instead of notebook js tests """ if options.testgroups: groups = options.testgroups else: groups = [''] return [ WidgetTestController(g, extra_args=options.extra_args) for g in...
def prepare_controllers(options):
"""Monkeypatched prepare_controllers for running widget js tests instead of notebook js tests """ if options.testgroups: groups = options.testgroups else: groups = [''] return [ WidgetTestController(g, extra_args=options.extra_args) for g in groups ], []
s' % self.engine] if extra_args is not None: self.cmd = self.cmd + extra_args def setup(self): super(WidgetTestController, self).setup() with patch.dict(os.environ, self.env): install(user=True, enable=True) def prepare_controllers(options):
64
64
70
6
58
wangyum/anaconda
pkgs/ipywidgets-4.1.1-py27_0/lib/python2.7/site-packages/ipywidgets/jstest.py
Python
prepare_controllers
prepare_controllers
40
49
40
40
d0a7801e1d81de24f9b1ed0045ec497f7ffbbe4e
bigcode/the-stack
train
1d167d32bd9efbcb0f3a9e94
train
function
def get_inner_expr_to_check(node): if is_inst(node): inners = get_inner_entities_list(node) else: inners = [node] expressions = filter(is_expr, inners) insns = filter(is_inst, inners) assert(len(insns) + len(expressions) == len(inners)) for j in insns: expressions += get_...
def get_inner_expr_to_check(node):
if is_inst(node): inners = get_inner_entities_list(node) else: inners = [node] expressions = filter(is_expr, inners) insns = filter(is_inst, inners) assert(len(insns) + len(expressions) == len(inners)) for j in insns: expressions += get_inner_expr_to_check(j) inner = ...
import ida_hexrays import Nodes def is_inst(node): return type(node) == type(ida_hexrays.cinsn_t()) def is_expr(node): return type(node) == type(ida_hexrays.cexpr_t()) def get_inner_expr_to_check(node):
61
64
114
8
53
v0s/HRAST
Patterns/traversal.py
Python
get_inner_expr_to_check
get_inner_expr_to_check
10
23
10
10
381a79817d736580157d45c3f4d3e474cdc88a17
bigcode/the-stack
train
3758c69df861766468c9b07c
train
function
def is_expr(node): return type(node) == type(ida_hexrays.cexpr_t())
def is_expr(node):
return type(node) == type(ida_hexrays.cexpr_t())
import ida_hexrays import Nodes def is_inst(node): return type(node) == type(ida_hexrays.cinsn_t()) def is_expr(node):
36
64
22
5
31
v0s/HRAST
Patterns/traversal.py
Python
is_expr
is_expr
7
8
7
7
a9365000e9d0fdb3482017b7830a989eb8362405
bigcode/the-stack
train
3c432a931e77680b3578dca0
train
function
def is_inst(node): return type(node) == type(ida_hexrays.cinsn_t())
def is_inst(node):
return type(node) == type(ida_hexrays.cinsn_t())
import ida_hexrays import Nodes def is_inst(node):
14
64
22
5
8
v0s/HRAST
Patterns/traversal.py
Python
is_inst
is_inst
4
5
4
4
f1e4386b7f685ff02fb016d115af36d8181ba1d8
bigcode/the-stack
train
94856e58455a915dc27e98a2
train
function
def get_inner_entities_list_expr(exp): opname = exp.opname if opname == 'var': """There is no expressions inside var""" return [] elif opname == "memptr": return [exp.x] + get_inner_entities_list_expr(exp.x) elif opname == "memref": return [exp.x] + get_inner_entities_lis...
def get_inner_entities_list_expr(exp):
opname = exp.opname if opname == 'var': """There is no expressions inside var""" return [] elif opname == "memptr": return [exp.x] + get_inner_entities_list_expr(exp.x) elif opname == "memref": return [exp.x] + get_inner_entities_list_expr(exp.x) elif opname == "ptr":...
elif opname == "switch": #TODO: do something return [] elif opname == "continue": return [] elif opname == "for": return filter(lambda x : x is not None, [node.cfor.init, node.cfor.expr, node.cfor.step, node.cfor.body]) elif opname == "empty": return [] else: ...
99
99
331
8
91
v0s/HRAST
Patterns/traversal.py
Python
get_inner_entities_list_expr
get_inner_entities_list_expr
60
86
60
60
96492469a8c914fdc65730e4387023685703ed98
bigcode/the-stack
train
8a1ba91e4e0c798ef2300c13
train
function
def get_inner_entities_list(node): opname = node.opname if opname == "block": return [x for x in node.cblock] elif opname == "expr": return [node.cexpr] elif opname == "if": ret = [node.cif.expr, node.cif.ithen] if node.cif.ielse is not None: ret.append(node.c...
def get_inner_entities_list(node):
opname = node.opname if opname == "block": return [x for x in node.cblock] elif opname == "expr": return [node.cexpr] elif opname == "if": ret = [node.cif.expr, node.cif.ithen] if node.cif.ielse is not None: ret.append(node.cif.ielse) return ret el...
, inners) insns = filter(is_inst, inners) assert(len(insns) + len(expressions) == len(inners)) for j in insns: expressions += get_inner_expr_to_check(j) inner = [] for i in expressions: inner += get_inner_entities_list_expr(i) return expressions + inner def get_inner_entities_lis...
81
81
273
7
73
v0s/HRAST
Patterns/traversal.py
Python
get_inner_entities_list
get_inner_entities_list
25
58
25
25
ad7c1edbcde21ec3bca2094f384dd98724e222dd
bigcode/the-stack
train
70f28a0132eacd81c05b5f91
train
class
class TestRealDelegate(unittest.TestCase): def setUp(self): self.delegate = update_nacl_manifest.RealDelegate() def testGetTrunkRevision(self): revision_dict = { '21.0.1180.80': '151582', '23.0.1271.89': '167132', '24.0.1305.4': '164971', } for version, revision in revision_dict.i...
class TestRealDelegate(unittest.TestCase):
def setUp(self): self.delegate = update_nacl_manifest.RealDelegate() def testGetTrunkRevision(self): revision_dict = { '21.0.1180.80': '151582', '23.0.1271.89': '167132', '24.0.1305.4': '164971', } for version, revision in revision_dict.iteritems(): self.assertEqual('trunk.%...
('checksum' not in archive) self.assertRaises(manifest_util.Error, manifest.Validate) manifest.Validate(add_missing_info=True) self.assertEqual(archive['size'], self.data_len) self.assertEqual(archive['checksum']['sha1'], self.sha1) class TestRealDelegate(unittest.TestCase):
64
64
118
8
56
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
TestRealDelegate
TestRealDelegate
787
799
787
787
b13cb991b72f924b7f5bf8a947b18a0b2b574704
bigcode/the-stack
train
0755bb6023797ee4c9ed203e
train
function
def GetPathFromHttpsUrl(url): assert url.startswith(HTTPS_BASE_URL) return url[len(HTTPS_BASE_URL):]
def GetPathFromHttpsUrl(url):
assert url.startswith(HTTPS_BASE_URL) return url[len(HTTPS_BASE_URL):]
def MakeGsUrl(rel_path): return update_nacl_manifest.GS_BUCKET_PATH + rel_path def GetPathFromGsUrl(url): assert url.startswith(update_nacl_manifest.GS_BUCKET_PATH) return url[len(update_nacl_manifest.GS_BUCKET_PATH):] def GetPathFromHttpsUrl(url):
64
64
27
8
56
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
GetPathFromHttpsUrl
GetPathFromHttpsUrl
62
64
62
62
55aa39c5677fd8d989ae59a45af7a7e1ff1a10ef
bigcode/the-stack
train
4739f1b4a04a53159e4d5020
train
function
def GetArchiveURL(basename, version): return urlparse.urljoin(HTTPS_BASE_URL, posixpath.join(version, basename))
def GetArchiveURL(basename, version):
return urlparse.urljoin(HTTPS_BASE_URL, posixpath.join(version, basename))
') OS_MLW = ('mac', 'linux', 'win') OS_ALL = ('all',) POST_STABLE = 'post_stable' STABLE = 'stable' BETA = 'beta' DEV = 'dev' CANARY = 'canary' def GetArchiveURL(basename, version):
64
64
29
10
54
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
GetArchiveURL
GetArchiveURL
44
45
44
44
0b094b8a438e0fa2e2e62ddb270edbe20b53310d
bigcode/the-stack
train
3e1d4c52a8e4c48e01d85953
train
function
def MakeNonPepperBundle(name, with_archives=False): bundle = manifest_util.Bundle(name) bundle.version = 1 bundle.revision = 1 bundle.description = 'Dummy bundle' bundle.recommended = 'yes' bundle.stability = 'stable' if with_archives: for host_os in OS_MLW: archive = manifest_util.Archive(host...
def MakeNonPepperBundle(name, with_archives=False):
bundle = manifest_util.Bundle(name) bundle.version = 1 bundle.revision = 1 bundle.description = 'Dummy bundle' bundle.recommended = 'yes' bundle.stability = 'stable' if with_archives: for host_os in OS_MLW: archive = manifest_util.Archive(host_os) archive.url = 'http://example.com' ...
MakePlatformArchive(host_os, version): return MakeArchive(GetPlatformArchiveUrl(host_os, version), host_os) def MakeNonPlatformArchive(basename, version): return MakeArchive(GetArchiveURL(basename, version), 'all') def MakeNonPepperBundle(name, with_archives=False):
64
64
126
13
51
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
MakeNonPepperBundle
MakeNonPepperBundle
85
100
85
85
8051d5e9d1368595a42c6ae5867695d2f88985be
bigcode/the-stack
train
ceb039990c68fb5980253ba2
train
class
class TestDelegate(update_nacl_manifest.Delegate): def __init__(self, manifest, history, files, version_mapping): self.manifest = manifest self.history = history self.files = files self.version_mapping = version_mapping self.dryrun = 0 self.called_gsutil_cp = False self.called_sendmail = F...
class TestDelegate(update_nacl_manifest.Delegate):
def __init__(self, manifest, history, files, version_mapping): self.manifest = manifest self.history = history self.files = files self.version_mapping = version_mapping self.dryrun = 0 self.called_gsutil_cp = False self.called_sendmail = False def GetRepoManifest(self): return self....
path = GetPathFromHttpsUrl(archive.url) self[path] = 'My Dummy archive' if add_json: # add .json manifest snippet, it should look like a normal Bundle, but # only has one archive. new_bundle = manifest_util.Bundle('') new_bundle.CopyFrom(bundle) del new_bundle.archives[:] ...
108
108
361
10
98
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
TestDelegate
TestDelegate
185
230
185
185
e016c28cc4b7c493f88df42329ea35ff4226fe65
bigcode/the-stack
train
c7227eaf33cb8cb34f243589
train
class
class MakeHistory(object): def __init__(self): # used for a dummy timestamp self.datetime = datetime.datetime.utcnow() self.history = [] def Add(self, host_oses, channel, version): for host_os in host_oses: timestamp = self.datetime.strftime('%Y-%m-%d %H:%M:%S.%f') self.history.append((...
class MakeHistory(object):
def __init__(self): # used for a dummy timestamp self.datetime = datetime.datetime.utcnow() self.history = [] def Add(self, host_oses, channel, version): for host_os in host_oses: timestamp = self.datetime.strftime('%Y-%m-%d %H:%M:%S.%f') self.history.append((host_os, channel, version, ...
class MakeManifest(manifest_util.SDKManifest): def __init__(self, *args): manifest_util.SDKManifest.__init__(self) for bundle in args: self.AddBundle(bundle) def AddBundle(self, bundle): self.MergeBundle(bundle, allow_existing=False) class MakeHistory(object):
64
64
122
5
59
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
MakeHistory
MakeHistory
146
157
146
146
652da81830573a32af0f5730aed306fda393aa4b
bigcode/the-stack
train
fb42b1c6c987311c48ddf41d
train
class
class MakeFiles(dict): def AddOnlineManifest(self, manifest_string): self['naclsdk_manifest2.json'] = manifest_string def Add(self, bundle, add_archive_for_os=OS_MLW, add_json_for_os=OS_MLW): for archive in bundle.GetArchives(): if not archive.host_os in add_archive_for_os: continue se...
class MakeFiles(dict):
def AddOnlineManifest(self, manifest_string): self['naclsdk_manifest2.json'] = manifest_string def Add(self, bundle, add_archive_for_os=OS_MLW, add_json_for_os=OS_MLW): for archive in bundle.GetArchives(): if not archive.host_os in add_archive_for_os: continue self.AddArchive(bundle, a...
-%m-%d %H:%M:%S.%f') self.history.append((host_os, channel, version, timestamp)) self.datetime += datetime.timedelta(0, -3600) # one hour earlier self.datetime += datetime.timedelta(-1) # one day earlier class MakeFiles(dict):
64
64
207
5
58
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
MakeFiles
MakeFiles
160
182
160
160
7bf2c449fe1ec9d867bd5851cb6b8f1bb2045444
bigcode/the-stack
train
6de4ab73ed09282c6df90290
train
function
def MakePepperBundle(major_version, revision=0, version=None, stability='dev'): assert (version is None or version.split('.')[0] == 'trunk' or version.split('.')[0] == str(major_version)) if stability == CANARY: bundle_name = CANARY_BUNDLE_NAME else: bundle_name = 'pepper_' + str(major...
def MakePepperBundle(major_version, revision=0, version=None, stability='dev'):
assert (version is None or version.split('.')[0] == 'trunk' or version.split('.')[0] == str(major_version)) if stability == CANARY: bundle_name = CANARY_BUNDLE_NAME else: bundle_name = 'pepper_' + str(major_version) bundle = manifest_util.Bundle(bundle_name) bundle.version = major...
ive(host_os) archive.url = 'http://example.com' archive.checksum = {'sha1': 'blah'} archive.size = 2 bundle.AddArchive(archive) return bundle def MakePepperBundle(major_version, revision=0, version=None, stability='dev'):
64
64
166
20
43
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
MakePepperBundle
MakePepperBundle
103
121
103
103
1a000c58bd19e441a9b2c21d419fec6129180480
bigcode/the-stack
train
0761547da7b0604dd8bfdb6f
train
function
def MakeArchive(url, host_os): archive = manifest_util.Archive(host_os) archive.url = url # dummy values that won't succeed if we ever use them, but will pass # validation. :) archive.checksum = {'sha1': 'foobar'} archive.size = 1 return archive
def MakeArchive(url, host_os):
archive = manifest_util.Archive(host_os) archive.url = url # dummy values that won't succeed if we ever use them, but will pass # validation. :) archive.checksum = {'sha1': 'foobar'} archive.size = 1 return archive
(url): assert url.startswith(update_nacl_manifest.GS_BUCKET_PATH) return url[len(update_nacl_manifest.GS_BUCKET_PATH):] def GetPathFromHttpsUrl(url): assert url.startswith(HTTPS_BASE_URL) return url[len(HTTPS_BASE_URL):] def MakeArchive(url, host_os):
64
64
70
8
56
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
MakeArchive
MakeArchive
67
74
67
67
7a92e130f3ebcb9221cc01a0d3a712a4db23c8d7
bigcode/the-stack
train
050c773ccfb63e0a8654c456
train
class
class TestUpdateManifest(unittest.TestCase): def setUp(self): self.history = MakeHistory() self.files = MakeFiles() self.version_mapping = {} self.delegate = None self.uploaded_manifest = None self.manifest = None # Ignore logging warnings, etc. logging.getLogger('update_nacl_manifest'...
class TestUpdateManifest(unittest.TestCase):
def setUp(self): self.history = MakeHistory() self.files = MakeFiles() self.version_mapping = {} self.delegate = None self.uploaded_manifest = None self.manifest = None # Ignore logging warnings, etc. logging.getLogger('update_nacl_manifest').setLevel(logging.CRITICAL) def _MakeDele...
B19_NONE = MakePlatformBundle(19) BCANARY_NONE = MakePlatformBundle(0, stability=CANARY) B21_0_1145_0_MLW = MakePlatformBundle(21, 138079, V21_0_1145_0, OS_MLW) B21_0_1166_0_MW = MakePlatformBundle(21, 140819, V21_0_1166_0, OS_MW) B26_NONE = MakePlatformBundle(26) B26_0_1386_0_MLW = MakePlatformBundle(26, 177362, V26_0...
256
256
6,010
8
248
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
TestUpdateManifest
TestUpdateManifest
261
746
261
261
f0245b81b9bcd39de9cfff8f3d30abd1a9016e44
bigcode/the-stack
train
60d216fe1f2bc284d6d01e32
train
function
def GetPlatformArchiveUrl(host_os, version): basename = 'naclsdk_%s.tar.bz2' % (host_os,) return GetArchiveURL(basename, version)
def GetPlatformArchiveUrl(host_os, version):
basename = 'naclsdk_%s.tar.bz2' % (host_os,) return GetArchiveURL(basename, version)
' STABLE = 'stable' BETA = 'beta' DEV = 'dev' CANARY = 'canary' def GetArchiveURL(basename, version): return urlparse.urljoin(HTTPS_BASE_URL, posixpath.join(version, basename)) def GetPlatformArchiveUrl(host_os, version):
64
64
41
10
54
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
GetPlatformArchiveUrl
GetPlatformArchiveUrl
48
50
48
48
942e11124429bbfa25c06e3fb94313998dcc33af
bigcode/the-stack
train
0991761c20e3fbe769eff4fc
train
function
def MakeNonPlatformArchive(basename, version): return MakeArchive(GetArchiveURL(basename, version), 'all')
def MakeNonPlatformArchive(basename, version):
return MakeArchive(GetArchiveURL(basename, version), 'all')
# validation. :) archive.checksum = {'sha1': 'foobar'} archive.size = 1 return archive def MakePlatformArchive(host_os, version): return MakeArchive(GetPlatformArchiveUrl(host_os, version), host_os) def MakeNonPlatformArchive(basename, version):
64
64
27
11
53
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
MakeNonPlatformArchive
MakeNonPlatformArchive
81
82
81
81
cf4e03088837cf152ec4bbc91d50ffbc011e44df
bigcode/the-stack
train
aebfc64dbff0cce3d11f736c
train
function
def MakePlatformArchive(host_os, version): return MakeArchive(GetPlatformArchiveUrl(host_os, version), host_os)
def MakePlatformArchive(host_os, version):
return MakeArchive(GetPlatformArchiveUrl(host_os, version), host_os)
ive(host_os) archive.url = url # dummy values that won't succeed if we ever use them, but will pass # validation. :) archive.checksum = {'sha1': 'foobar'} archive.size = 1 return archive def MakePlatformArchive(host_os, version):
64
64
25
9
54
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
MakePlatformArchive
MakePlatformArchive
77
78
77
77
2391d262a6fafca206b1c3b9ecf974dad0553cbc
bigcode/the-stack
train
acf08b68134bf9c14559e72b
train
class
class MakeManifest(manifest_util.SDKManifest): def __init__(self, *args): manifest_util.SDKManifest.__init__(self) for bundle in args: self.AddBundle(bundle) def AddBundle(self, bundle): self.MergeBundle(bundle, allow_existing=False)
class MakeManifest(manifest_util.SDKManifest):
def __init__(self, *args): manifest_util.SDKManifest.__init__(self) for bundle in args: self.AddBundle(bundle) def AddBundle(self, bundle): self.MergeBundle(bundle, allow_existing=False)
, stability='dev'): bundle = MakePepperBundle(major_version, revision, version, stability) if host_oses: for host_os in host_oses: bundle.AddArchive(MakePlatformArchive(host_os, version)) return bundle class MakeManifest(manifest_util.SDKManifest):
64
64
59
9
54
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
MakeManifest
MakeManifest
135
143
135
135
b909104d187733b0b0909b7958fb197eaa15dba1
bigcode/the-stack
train
912876c7583289f81102ae9e
train
class
class TestUpdateVitals(unittest.TestCase): def setUp(self): f = tempfile.NamedTemporaryFile('w', prefix="test_update_nacl_manifest") self.test_file = f.name f.close() test_data = "Some test data" self.sha1 = hashlib.sha1(test_data).hexdigest() self.data_len = len(test_data) with open(self....
class TestUpdateVitals(unittest.TestCase):
def setUp(self): f = tempfile.NamedTemporaryFile('w', prefix="test_update_nacl_manifest") self.test_file = f.name f.close() test_data = "Some test data" self.sha1 = hashlib.sha1(test_data).hexdigest() self.data_len = len(test_data) with open(self.test_file, 'w') as f: f.write(test_da...
have an online version, therefore there is # no good version number to upload. # # Basically we're asserting that 26.0.1386.1 != 26.0.1386.0, which would be # true if it were canary. self.assertRaises(update_nacl_manifest.UnknownLockedBundleException, self._Run, OS_MLW) class ...
89
89
299
8
81
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
TestUpdateVitals
TestUpdateVitals
749
784
749
749
5bfcf6e1c7f5d737855333978f84ed89f385be43
bigcode/the-stack
train
0f32d2088ff4f4a95318bd6e
train
function
def MakePlatformBundle(major_version, revision=0, version=None, host_oses=None, stability='dev'): bundle = MakePepperBundle(major_version, revision, version, stability) if host_oses: for host_os in host_oses: bundle.AddArchive(MakePlatformArchive(host_os, version)) return bundle
def MakePlatformBundle(major_version, revision=0, version=None, host_oses=None, stability='dev'):
bundle = MakePepperBundle(major_version, revision, version, stability) if host_oses: for host_os in host_oses: bundle.AddArchive(MakePlatformArchive(host_os, version)) return bundle
_version, revision) bundle.repath = 'pepper_' + str(major_version) bundle.recommended = 'no' bundle.stability = stability return bundle def MakePlatformBundle(major_version, revision=0, version=None, host_oses=None, stability='dev'):
64
64
74
25
38
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
MakePlatformBundle
MakePlatformBundle
124
132
124
125
c4c1f4382a273a7da8e6856b545d17cb4b51d116
bigcode/the-stack
train
fd03aa7be7170323a8eceed6
train
function
def GetPathFromGsUrl(url): assert url.startswith(update_nacl_manifest.GS_BUCKET_PATH) return url[len(update_nacl_manifest.GS_BUCKET_PATH):]
def GetPathFromGsUrl(url):
assert url.startswith(update_nacl_manifest.GS_BUCKET_PATH) return url[len(update_nacl_manifest.GS_BUCKET_PATH):]
_os, version): basename = 'naclsdk_%s.tar.bz2' % (host_os,) return GetArchiveURL(basename, version) def MakeGsUrl(rel_path): return update_nacl_manifest.GS_BUCKET_PATH + rel_path def GetPathFromGsUrl(url):
64
64
35
8
55
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
GetPathFromGsUrl
GetPathFromGsUrl
57
59
57
57
327e39200847cd66c168085be8a78dfcfdc80095
bigcode/the-stack
train
798e1d80c69c3bac629a9efe
train
function
def MakeGsUrl(rel_path): return update_nacl_manifest.GS_BUCKET_PATH + rel_path
def MakeGsUrl(rel_path):
return update_nacl_manifest.GS_BUCKET_PATH + rel_path
parse.urljoin(HTTPS_BASE_URL, posixpath.join(version, basename)) def GetPlatformArchiveUrl(host_os, version): basename = 'naclsdk_%s.tar.bz2' % (host_os,) return GetArchiveURL(basename, version) def MakeGsUrl(rel_path):
64
64
21
7
57
nagineni/chromium-crosswalk
native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
Python
MakeGsUrl
MakeGsUrl
53
54
53
53
2f18117089c98411773170cf995168bc15a94faf
bigcode/the-stack
train
ccf359ffa5160d505cccb168
train
class
class SenCNN(tf.keras.Model): def __init__(self, vocab, classes): super(SenCNN, self).__init__() self._embedding = MultiChannelEmbedding(vocab) self._conv = ConvolutionLayer(300) # maxpooling self._maxpooling = MaxPooling() self._dropout = tf.keras.layers.Dropout(.5)...
class SenCNN(tf.keras.Model):
def __init__(self, vocab, classes): super(SenCNN, self).__init__() self._embedding = MultiChannelEmbedding(vocab) self._conv = ConvolutionLayer(300) # maxpooling self._maxpooling = MaxPooling() self._dropout = tf.keras.layers.Dropout(.5) self._fc = tf.keras.l...
import tensorflow as tf from model.ops import MultiChannelEmbedding, ConvolutionLayer, MaxPooling from configs import FLAGS class SenCNN(tf.keras.Model):
32
64
152
7
24
modudeepnlp/NLP_Tensorflow2.0
jmkim/CNN_SC/model/net.py
Python
SenCNN
SenCNN
7
25
7
7
0e88f4838112f9ab754f27c58e43e7f137a3b14e
bigcode/the-stack
train
284e04d93b4a7cabd5045680
train
class
class RocmTensile(CMakePackage): """Radeon Open Compute Tensile library""" homepage = "https://github.com/ROCmSoftwarePlatform/Tensile/" git = "https://github.com/ROCmSoftwarePlatform/Tensile.git" url = "https://github.com/ROCmSoftwarePlatform/Tensile/archive/rocm-4.5.0.tar.gz" maintaine...
class RocmTensile(CMakePackage):
"""Radeon Open Compute Tensile library""" homepage = "https://github.com/ROCmSoftwarePlatform/Tensile/" git = "https://github.com/ROCmSoftwarePlatform/Tensile.git" url = "https://github.com/ROCmSoftwarePlatform/Tensile/archive/rocm-4.5.0.tar.gz" maintainers = ['srekolam', 'arjun-raj-kupp...
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class RocmTensile(CMakePackage):
64
256
1,896
10
54
keerthana4708/spack
var/spack/repos/builtin/packages/rocm-tensile/package.py
Python
RocmTensile
RocmTensile
10
112
10
10
369ba7724a2f3e34d60f1ac52ffa93e9a713b55c
bigcode/the-stack
train
b67791595b12cd6a33d355d0
train
class
class btcalpha(Exchange): def describe(self): return self.deep_extend(super(btcalpha, self).describe(), { 'id': 'btcalpha', 'name': 'BTC-Alpha', 'countries': ['US'], 'version': 'v1', 'has': { 'CORS': None, 'spot': T...
class btcalpha(Exchange):
def describe(self): return self.deep_extend(super(btcalpha, self).describe(), { 'id': 'btcalpha', 'name': 'BTC-Alpha', 'countries': ['US'], 'version': 'v1', 'has': { 'CORS': None, 'spot': True, 'margi...
# -*- coding: utf-8 -*- # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN: # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code from ccxt.base.exchange import Exchange from ccxt.base.errors import ExchangeError from ccxt.base.errors import AuthenticationError from cc...
126
256
4,295
7
118
alanwu4321/ccxt
python/ccxt/btcalpha.py
Python
btcalpha
btcalpha
15
534
15
16
1c4f59d9268185b75be57c9fbc47488dc16a3e21
bigcode/the-stack
train
02c80e4d9d959cabe2438dd8
train
function
def del_bookmark(cfg, args): """Delete a bookmark from the system. Admins can specify a username with --username flag. """ api = BmarkApi(cfg.api_url, cfg.username, cfg.api_key) username = cfg.username is_admin = False if args.username: username = args.username is_admin = T...
def del_bookmark(cfg, args):
"""Delete a bookmark from the system. Admins can specify a username with --username flag. """ api = BmarkApi(cfg.api_url, cfg.username, cfg.api_key) username = cfg.username is_admin = False if args.username: username = args.username is_admin = True api.delete(username,...
cfg.username, cfg.api_key) api.new_user(args.username, args.email) def del_user(cfg, args): """Remove a user from the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.del_user(args.username) def del_bookmark(cfg, args):
64
64
91
8
56
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
del_bookmark
del_bookmark
79
92
79
79
4ce561058b79a7636810f5874fbd59fd3e47eacf
bigcode/the-stack
train
2ee1e69112f682afe091865d
train
function
def invite_list(cfg, args): """Handle the invite list call.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.invite_status()
def invite_list(cfg, args):
"""Handle the invite list call.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.invite_status()
_url, cfg.username, cfg.api_key) api.to_readable() def readable_reindex(cfg, args): """Reindex all the bookmarks in the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.readable_reindex() def invite_list(cfg, args):
64
64
37
7
57
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
invite_list
invite_list
37
40
37
37
1089e5bc5a7f8a4445631eb454d8f9d302f3d3a5
bigcode/the-stack
train
ed1b4c4e55a09b5f1fa6836d
train
function
def to_readable(cfg, args): """Check the list of urls we need to readable parse still.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.to_readable()
def to_readable(cfg, args):
"""Check the list of urls we need to readable parse still.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.to_readable()
Admin Commands # ############### def applog(cfg, args): """Load the applog entries.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.applog( args.days, args.status, args.filter) def to_readable(cfg, args):
64
64
44
8
56
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
to_readable
to_readable
26
29
26
26
7e60ae5cfa54c189cc9db056bc36e081d7b78ff0
bigcode/the-stack
train
33e93b042f49daedacc5e9f8
train
function
def applog(cfg, args): """Load the applog entries.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.applog( args.days, args.status, args.filter)
def applog(cfg, args):
"""Load the applog entries.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.applog( args.days, args.status, args.filter)
# # User Commands # ############# def ping(cfg, args): """Perform a ping to check config.""" api = UserApi(cfg.api_url, cfg.username, cfg.api_key) api.ping() # ############### # Admin Commands # ############### def applog(cfg, args):
64
64
49
7
57
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
applog
applog
18
24
18
18
a4d61a499638a68763c2ac4b30ae0e7a7986f1f9
bigcode/the-stack
train
16ad3126fb663253cc1ec15f
train
function
def invite_set(cfg, args): """Handle the invite set call to add invites to a user.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.invite_set(args.username, args.invite_ct)
def invite_set(cfg, args):
"""Handle the invite set call to add invites to a user.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.invite_set(args.username, args.invite_ct)
AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.readable_reindex() def invite_list(cfg, args): """Handle the invite list call.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.invite_status() def invite_set(cfg, args):
64
64
50
7
57
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
invite_set
invite_set
43
46
43
43
e9db580f9cdbb9f77df549f72c2fcfaa8e223d62
bigcode/the-stack
train
16cf61fcb5dd969a683b4fa4
train
function
def import_list(cfg, args): """Fetch some data """ api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.import_list()
def import_list(cfg, args):
"""Fetch some data """ api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.import_list()
) api.invite_status() def invite_set(cfg, args): """Handle the invite set call to add invites to a user.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.invite_set(args.username, args.invite_ct) def import_list(cfg, args):
64
64
34
7
57
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
import_list
import_list
49
52
49
49
eaf0d297c98bbd9f13f40b5c81b687e5913d5e3e
bigcode/the-stack
train
e9e797734fa2e5b30eb95b85
train
function
def ping(cfg, args): """Perform a ping to check config.""" api = UserApi(cfg.api_url, cfg.username, cfg.api_key) api.ping()
def ping(cfg, args):
"""Perform a ping to check config.""" api = UserApi(cfg.api_url, cfg.username, cfg.api_key) api.ping()
from bookie_api.api import AdminApi from bookie_api.api import BmarkApi from bookie_api.api import UserApi # ############# # User Commands # ############# def ping(cfg, args):
46
64
36
6
40
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
ping
ping
9
12
9
9
723b03201d1b695b6fddb14f3e6dba4da4ba4287
bigcode/the-stack
train
c95654e9209033119ac47b17
train
function
def import_reset(cfg, args): """Reset an import back to reprocess""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.import_reset(args.id)
def import_reset(cfg, args):
"""Reset an import back to reprocess""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.import_reset(args.id)
.api_url, cfg.username, cfg.api_key) api.invite_set(args.username, args.invite_ct) def import_list(cfg, args): """Fetch some data """ api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.import_list() def import_reset(cfg, args):
64
64
40
7
57
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
import_reset
import_reset
55
58
55
55
9abc6e1babcf33931b606cf3aa50bb859a86b8f2
bigcode/the-stack
train
b62de687d653afcf8e815a60
train
function
def del_user(cfg, args): """Remove a user from the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.del_user(args.username)
def del_user(cfg, args):
"""Remove a user from the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.del_user(args.username)
_url, cfg.username, cfg.api_key) api.user_list() def user_add(cfg, args): """Add a new user to the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.new_user(args.username, args.email) def del_user(cfg, args):
64
64
39
7
57
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
del_user
del_user
73
76
73
73
ead7cf8869a0282eecfae45a7f223d9029b2ca8e
bigcode/the-stack
train
cb25cd6a52ca8c62e3ca7a62
train
function
def user_add(cfg, args): """Add a new user to the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.new_user(args.username, args.email)
def user_add(cfg, args):
"""Add a new user to the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.new_user(args.username, args.email)
AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.import_reset(args.id) def user_list(cfg, args): """List the users in the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.user_list() def user_add(cfg, args):
64
64
43
7
57
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
user_add
user_add
67
70
67
67
eef430e813953ff170e6d21d1eaf3bfa564080c9
bigcode/the-stack
train
c5897f8b4658b39b9d8e5f79
train
function
def user_list(cfg, args): """List the users in the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.user_list()
def user_list(cfg, args):
"""List the users in the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.user_list()
Api(cfg.api_url, cfg.username, cfg.api_key) api.import_list() def import_reset(cfg, args): """Reset an import back to reprocess""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.import_reset(args.id) def user_list(cfg, args):
64
64
37
7
57
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
user_list
user_list
61
64
61
61
c661d9723c599939f960c3dd88a34dfd1ce32c78
bigcode/the-stack
train
29e340b8e648798e993cffb7
train
function
def readable_reindex(cfg, args): """Reindex all the bookmarks in the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.readable_reindex()
def readable_reindex(cfg, args):
"""Reindex all the bookmarks in the system.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.readable_reindex()
args.days, args.status, args.filter) def to_readable(cfg, args): """Check the list of urls we need to readable parse still.""" api = AdminApi(cfg.api_url, cfg.username, cfg.api_key) api.to_readable() def readable_reindex(cfg, args):
64
64
42
8
56
harshp8l/deep-learning-lang-detection
data/train/python/de266ce274642b91834fef8d954623c26d1a0581commands.py
Python
readable_reindex
readable_reindex
31
34
31
31
d744e5b0ed6838574029ee977368f1e50aa0ca58
bigcode/the-stack
train
adef87bbcf0abf08e68391e7
train
function
def config_test(**kwargs): """Test rule that fails if a project config is not valid. Args: **kwargs: Same attrs of _config_test. """ if "deps" in kwargs and kwargs["deps"] == []: fail("`deps` is specified but resolved to no file. It might be because your glob() pattern contains typos.") ...
def config_test(**kwargs):
"""Test rule that fails if a project config is not valid. Args: **kwargs: Same attrs of _config_test. """ if "deps" in kwargs and kwargs["deps"] == []: fail("`deps` is specified but resolved to no file. It might be because your glob() pattern contains typos.") _config_test(**kwargs)
default = Label("//:project_config.yaml.schema"), doc = "The project config schema. Internal attribute and should not be set by users.", cfg = "host", allow_single_file = True, ), }, test = True, implementation = _impl, ) def config_test(**kwargs):
64
64
84
6
58
rczhang/healthcare
deploy/starlark/config_test.bzl
Python
config_test
config_test
79
88
79
79
0cdbc23691ef071aec42f2ad2cf6050c3e029e15
bigcode/the-stack
train
4c3486e5f79bd9670015077d
train
function
def _impl(ctx): """Core implementation of _config_test rule.""" if ctx.attr.projects: content = "{apply} --dry_run --config_path={config_path} --enable_terraform={enable_terraform} --projects={projects} --terraform_configs_dir=$TEST_UNDECLARED_OUTPUTS_DIR/dpt".format( apply = ctx.executable....
def _impl(ctx):
"""Core implementation of _config_test rule.""" if ctx.attr.projects: content = "{apply} --dry_run --config_path={config_path} --enable_terraform={enable_terraform} --projects={projects} --terraform_configs_dir=$TEST_UNDECLARED_OUTPUTS_DIR/dpt".format( apply = ctx.executable._apply.short_pat...
"""Test rule that fails if a project config is not valid.""" def _impl(ctx):
18
82
274
5
13
rczhang/healthcare
deploy/starlark/config_test.bzl
Python
_impl
_impl
3
32
3
3
93d565fd9278a97074f43bb0d0379adc78a0b2fc
bigcode/the-stack
train
7006da99b4be699a3badcefe
train
function
def read_RAMAN_WITEC_2D(file, lbd_dep=None, lbd_end=None): """ Read a WITEC Raman hyperspectrastored in .txt format The first column label is : 'X-Axis' second : 'Large Area Scan_000_Spec.Data 1(0/0)' last : 'Large Area Scan_000_Spec.Data 1(I_col/I_r...
def read_RAMAN_WITEC_2D(file, lbd_dep=None, lbd_end=None):
""" Read a WITEC Raman hyperspectrastored in .txt format The first column label is : 'X-Axis' second : 'Large Area Scan_000_Spec.Data 1(0/0)' last : 'Large Area Scan_000_Spec.Data 1(I_col/I_row)' where I_col and Irow are the latest index of the col...
ra_nane (sring): name of the hyperspectra Returns: da (xarray): hyperspectrum """ # 3rd party dependencies import xarray as xr import numpy as np spectral_resolution = np.mean(np.diff(lbd)) da = xr.DataArray( Intensity, dims=["y", "x", "lbd"], ...
256
256
988
22
233
Bertin-fap/raman_hyperspectra
raman_hyperspectra/raman_hyperspectra/raman_hyperspectra_read_files.py
Python
read_RAMAN_WITEC_2D
read_RAMAN_WITEC_2D
201
304
201
202
18f0ff88215c3270862dd64654ce465f4f8b4541
bigcode/the-stack
train
c3ed5bc97523117a0d5287e3
train
function
def read_RAMAN_WITEC_information(file): """ Read an information file, file, provided by WITEC. Arguments: file : the documentation file Returns: dic_info : dictionary with keys : Points per Line, Lines per Image, Scan Width [µm], Scan Height ...
def read_RAMAN_WITEC_information(file):
""" Read an information file, file, provided by WITEC. Arguments: file : the documentation file Returns: dic_info : dictionary with keys : Points per Line, Lines per Image, Scan Width [µm], Scan Height [µm], Scan Origin X [µm], Scan Origin Y [µm...
da_sliced_interp.lbd.values)), "units": "cm-1", "spectrum type": "sliced interp", "shift correction": "no", } return da_sliced, da_sliced_interp, da, da_interp def read_RAMAN_WITEC_information(file):
64
64
189
10
53
Bertin-fap/raman_hyperspectra
raman_hyperspectra/raman_hyperspectra/raman_hyperspectra_read_files.py
Python
read_RAMAN_WITEC_information
read_RAMAN_WITEC_information
307
333
307
308
9e5d5ba4d81642383f62f8f9da6e950bb321fca7
bigcode/the-stack
train
5e0805a120cc5db16faa06af
train
function
def construct_xarray_0D(spectrum, lbd, tool="WITEK", hyperspectra_name="unknown"): """ construct the xarray of a spectrum Arguments: spectrum (np array): spectrum intensities lbd (np array): vawelengths tool (string) : name of thRaman equipment hyperspectra_nane (s...
def construct_xarray_0D(spectrum, lbd, tool="WITEK", hyperspectra_name="unknown"):
""" construct the xarray of a spectrum Arguments: spectrum (np array): spectrum intensities lbd (np array): vawelengths tool (string) : name of thRaman equipment hyperspectra_nane (sring): name of the hyperspectra Returns: da (xarray): spectrum ""...
_interp = construct_xarray_0D( spectrum, lbd, tool="WITEK", hyperspectra_name=hyperspectra_name ) return da_sliced, da_sliced_interp, da, da_interp def construct_xarray_0D(spectrum, lbd, tool="WITEK", hyperspectra_name="unknown"):
77
77
258
27
49
Bertin-fap/raman_hyperspectra
raman_hyperspectra/raman_hyperspectra/raman_hyperspectra_read_files.py
Python
construct_xarray_0D
construct_xarray_0D
109
148
109
110
b1969271723af7155d42b99e732078240b911144
bigcode/the-stack
train
b7c76317b9ea07c2f69ee4d7
train
function
def read_RENISHAW_1D_wdf(file, lbd_dep=None, lbd_end=None): """ Read a Raman spectra stored in .wdf (RENIHAW format) base on the package renishawWiRE We assert that the spectral unit is expressed in cm-1 (Raman shift) Arguments: file (string): name of the file containing the hyperspe...
def read_RENISHAW_1D_wdf(file, lbd_dep=None, lbd_end=None):
""" Read a Raman spectra stored in .wdf (RENIHAW format) base on the package renishawWiRE We assert that the spectral unit is expressed in cm-1 (Raman shift) Arguments: file (string): name of the file containing the hyperspectra lbd_dep (real): first wavelength [cm-1] (default = ...
type": "sliced raw", "shift correction": "no", } lbd_interp = np.arange( da_sliced.lbd.values[0], da_sliced.lbd.values[-1], min(np.diff(da_sliced.lbd.values)), ) da_sliced_interp = da_sliced.interp(lbd=lbd_interp, method="cubic") da_sliced_interp.lbd.attrs...
189
189
631
24
164
Bertin-fap/raman_hyperspectra
raman_hyperspectra/raman_hyperspectra/raman_hyperspectra_read_files.py
Python
read_RENISHAW_1D_wdf
read_RENISHAW_1D_wdf
488
556
488
489
d1f26ed1dbb00e1cece7eb07653f2534a969a178
bigcode/the-stack
train
b948768f7763484f39bea9a1
train
function
def construct_xarray( Intensity, x, y, lbd, units="u.a.", tool="WITEK", hyperspectra_name="unknown" ): """ construct the xarray of a hyperspectrum Arguments: spectrum (np array): hyperspectrum intensities values lbd (np array): vawelengths x (np array): x location of ...
def construct_xarray( Intensity, x, y, lbd, units="u.a.", tool="WITEK", hyperspectra_name="unknown" ):
""" construct the xarray of a hyperspectrum Arguments: spectrum (np array): hyperspectrum intensities values lbd (np array): vawelengths x (np array): x location of the spectrum express in index (WITEk), distance (RENISHAW) y (np array): y location of the spectrum exp...
": tool, "hyperspectra_name": hyperspectra_name}, coords={ "lbd": xr.DataArray( lbd, name="lbd", dims=["lbd"], attrs={ "units": "cm-1", "spectral_resolution": spectral_resolution, ...
121
121
405
35
85
Bertin-fap/raman_hyperspectra
raman_hyperspectra/raman_hyperspectra/raman_hyperspectra_read_files.py
Python
construct_xarray
construct_xarray
151
198
151
154
88e049ece307dac57df8c1aa4c1641900602fc60
bigcode/the-stack
train
9e1df944d15bf12ed0966c59
train
function
def read_RAMAN_RENISHAW_txt_2D(file, lbd_dep=None, lbd_end=None): """ Read a RENISHAW Raman hyperspectrastored in .txt format Arguments: file (string): name of the file containing the hyperspectra lbd_dep (real): first wavelength [cm-1] (default = None) led_end (real): end waveleng...
def read_RAMAN_RENISHAW_txt_2D(file, lbd_dep=None, lbd_end=None):
""" Read a RENISHAW Raman hyperspectrastored in .txt format Arguments: file (string): name of the file containing the hyperspectra lbd_dep (real): first wavelength [cm-1] (default = None) led_end (real): end wavelength [cm-1] (default = None) Returns: da (xarray): full...
.path.basename(file) da = construct_xarray_0D( spectrum, lbd, tool="RENIHAW", hyperspectra_name=hyperspectra_name ) lbd = np.arange(da.lbd.values[0], da.lbd.values[-1], min(np.diff(da.lbd.values))) spectrum = da.interp(lbd=lbd, method="cubic") da_interp = construct_xarray_0D(spectr...
253
253
845
25
227
Bertin-fap/raman_hyperspectra
raman_hyperspectra/raman_hyperspectra/raman_hyperspectra_read_files.py
Python
read_RAMAN_RENISHAW_txt_2D
read_RAMAN_RENISHAW_txt_2D
396
485
396
396
cb8222144b253bd8e958e3d28bb0a83f8feaee13
bigcode/the-stack
train
2d1384ff1aef1389fe83298d
train
function
def read_RAMAN_WITEC_0D(file, lbd_dep=None, lbd_end=None): """ Read a Raman spectra WITEC stored in .txt format Arguments: file (string): name of the file containing the hyperspectra lbd_dep (real): first wavelength [cm-1] (default = None) led_end (real): end wavelength [cm-1] (d...
def read_RAMAN_WITEC_0D(file, lbd_dep=None, lbd_end=None):
""" Read a Raman spectra WITEC stored in .txt format Arguments: file (string): name of the file containing the hyperspectra lbd_dep (real): first wavelength [cm-1] (default = None) led_end (real): end wavelength [cm-1] (default = None) Returns: da (xarray): full spectr...
325103, 'shift correction': 'yes', 'spectrum type': 'sliced raw'} 3rd parties dependencies : numpy, pandas, xarray """ __all__ = [ "read_RAMAN_WITEC_0D", "read_RAMAN_WITEC_2D", "read_RAMAN_WITEC_information", "read_RAMAN_RENISHAW_txt_0D", "read_RAMAN_RENISHAW_txt_2D", "construct...
169
170
569
22
147
Bertin-fap/raman_hyperspectra
raman_hyperspectra/raman_hyperspectra/raman_hyperspectra_read_files.py
Python
read_RAMAN_WITEC_0D
read_RAMAN_WITEC_0D
44
106
44
45
6a538c4117ecd8027a721644632664869183fefd
bigcode/the-stack
train
3ba7e811621274f4e4c64603
train
function
def read_RAMAN_RENISHAW_txt_0D(file, lbd_dep=None, lbd_end=None): """ Read a Raman spectra RENISHAW stored in .txt format Arguments: file (string): name of the file containing the hyperspectra lbd_dep (real): first wavelength [cm-1] (default = None) led_end (real): end wavelength...
def read_RAMAN_RENISHAW_txt_0D(file, lbd_dep=None, lbd_end=None):
""" Read a Raman spectra RENISHAW stored in .txt format Arguments: file (string): name of the file containing the hyperspectra lbd_dep (real): first wavelength [cm-1] (default = None) led_end (real): end wavelength [cm-1] (default = None) Returns: da (xarray): full spe...
per Image, Scan Width [µm], Scan Height [µm], Scan Origin X [µm], Scan Origin Y [µm] Scan Origin Z [µm], Gamma [°], Scan Speed [s/Line], Integration Time [s] """ # Standard Library depend...
162
162
541
25
136
Bertin-fap/raman_hyperspectra
raman_hyperspectra/raman_hyperspectra/raman_hyperspectra_read_files.py
Python
read_RAMAN_RENISHAW_txt_0D
read_RAMAN_RENISHAW_txt_0D
336
393
336
337
47e84d6dc9e20f75ee6e60f3774be82b6a5e8a03
bigcode/the-stack
train
1653c778140032d736c6ef3a
train
function
def read_RENISHAW_2D_wdf(file, lbd_dep=None, lbd_end=None): """ Read a Raman hyperspectra stored in .wdf (RENISHAW format) base on the package renishawWiRE. We assert that: (i)the spectral unit is expressed in cm-1 (Raman shift); (ii) the unit of x and y axes are equal Arguments: fil...
def read_RENISHAW_2D_wdf(file, lbd_dep=None, lbd_end=None):
""" Read a Raman hyperspectra stored in .wdf (RENISHAW format) base on the package renishawWiRE. We assert that: (i)the spectral unit is expressed in cm-1 (Raman shift); (ii) the unit of x and y axes are equal Arguments: file (string): name of the file containing the hyperspectra ...
ra_name = os.path.basename(file) da = construct_xarray_0D( spectrum, lbd, tool="RENIHAW", hyperspectra_name=hyperspectra_name ) lbd = np.arange(da.lbd.values[0], da.lbd.values[-1], min(np.diff(da.lbd.values))) spectrum = da.interp(lbd=lbd, method="cubic") da_interp = construct_xarr...
256
256
943
24
231
Bertin-fap/raman_hyperspectra
raman_hyperspectra/raman_hyperspectra/raman_hyperspectra_read_files.py
Python
read_RENISHAW_2D_wdf
read_RENISHAW_2D_wdf
559
660
559
560
11c2a9bd86b894df96d7881a67464a9ada4e6786
bigcode/the-stack
train
9574e4ee2c39a16004c5809f
train
class
@final class ImplicitComplexCompareViolation(ASTViolation): """ Forbids to have implicit complex compare expressions. Reasoning: Two compares in python that are joined with ``and`` operator mean that you indeed have a complex compare with tree operators. Solution: Refactor your...
@final class ImplicitComplexCompareViolation(ASTViolation):
""" Forbids to have implicit complex compare expressions. Reasoning: Two compares in python that are joined with ``and`` operator mean that you indeed have a complex compare with tree operators. Solution: Refactor your compare without ``and`` but with the third operator. ...
one if cond() else two # Wrong: some = cond() and one or two .. versionadded:: 0.10.0 """ code = 332 error_template = 'Found implicit ternary expression' @final class ImplicitComplexCompareViolation(ASTViolation):
64
64
149
12
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ImplicitComplexCompareViolation
ImplicitComplexCompareViolation
1,319
1,347
1,319
1,320
82aa50ec6da817c003e11c5cfc33c56f40b6e75a
bigcode/the-stack
train
041b004cde316c4f03cde969
train
class
@final class ParametersIndentationViolation(ASTViolation): """ Forbids to use incorrect parameters indentation. Reasoning: It is really easy to spoil your perfect, readable code with incorrect multi-line parameters indentation. Since it is really easy to style them in any of 100 pos...
@final class ParametersIndentationViolation(ASTViolation):
""" Forbids to use incorrect parameters indentation. Reasoning: It is really easy to spoil your perfect, readable code with incorrect multi-line parameters indentation. Since it is really easy to style them in any of 100 possible ways. We enforce a strict rule about how it i...
Use several context managers. Or explicit brackets. Example:: # Correct: with open('') as first: with second: ... with some_context as (first, second): ... # Wrong: with open('') as first, second: ... .. ver...
103
103
345
11
91
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ParametersIndentationViolation
ParametersIndentationViolation
694
760
694
695
46af30dc76c4074810ddb4834b42021ca5d26c51
bigcode/the-stack
train
a11374a4ed301da998dcab83
train
class
@final class ImplicitStringConcatenationViolation(TokenizeViolation): """ Forbids to use implicit string concatenation. Reasoning: This is error-prone, since you can possibly miss a comma in a collection of string and get an implicit concatenation. And because there are different an...
@final class ImplicitStringConcatenationViolation(TokenizeViolation):
""" Forbids to use implicit string concatenation. Reasoning: This is error-prone, since you can possibly miss a comma in a collection of string and get an implicit concatenation. And because there are different and safe ways to do the same thing it is better to use them inst...
: def function(): if some: yield yield 1 .. versionadded:: 0.7.0 """ error_template = 'Found inconsistent `yield` statement' code = 325 @final class ImplicitStringConcatenationViolation(TokenizeViolation):
64
64
163
15
48
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ImplicitStringConcatenationViolation
ImplicitStringConcatenationViolation
1,090
1,117
1,090
1,091
f7acc3973ae4e76324c4c30dbf6de3e8247058c1
bigcode/the-stack
train
8dd2b54bd1bf7c50f09628ac
train
class
@final class WrongMethodOrderViolation(ASTViolation): """ Forbids to have incorrect order of methods inside a class. We follow the same ordering: - ``__new__`` - ``__init__`` - public and megic methods - protected methods - private methods (we discourage using them) We follow "New...
@final class WrongMethodOrderViolation(ASTViolation):
""" Forbids to have incorrect order of methods inside a class. We follow the same ordering: - ``__new__`` - ``__init__`` - public and megic methods - protected methods - private methods (we discourage using them) We follow "Newspaper order" when the most important things come the ...
, ): ... .. versionadded:: 0.9.0 .. versionchanged:: 0.11.0 """ error_template = 'Found multiline conditions' code = 337 previous_codes = {465} @final class WrongMethodOrderViolation(ASTViolation):
64
64
183
11
53
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
WrongMethodOrderViolation
WrongMethodOrderViolation
1,494
1,522
1,494
1,495
a185706ba10f30124d67743f53b4a6c3cc050f14
bigcode/the-stack
train
473f3114f40cbab67603673b
train
class
@final class ObjectInBaseClassesListViolation(ASTViolation): """ Forbids extra ``object`` in parent classes list. Reasoning: We should allow object only when we explicitly use it as a single parent class. When there is another class or there are multiple parents - we should ...
@final class ObjectInBaseClassesListViolation(ASTViolation):
""" Forbids extra ``object`` in parent classes list. Reasoning: We should allow object only when we explicitly use it as a single parent class. When there is another class or there are multiple parents - we should not allow it for the consistency reasons. Solution: ...
# Correct: if value is True: ... # Wrong: if True: ... .. versionadded:: 0.3.0 """ error_template = 'Conditional always evaluates to same result' code = 314 @final class ObjectInBaseClassesListViolation(ASTViolation):
64
64
176
13
50
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ObjectInBaseClassesListViolation
ObjectInBaseClassesListViolation
629
657
629
630
7f84b20130718c0cd0ef61891c7999d681d7f856
bigcode/the-stack
train
46ba898980d16a90caad3c2d
train
class
@final class FormattedStringViolation(ASTViolation): """ Forbids to use ``f`` strings. Reasoning: ``f`` strings loses context too often and they are hard to lint. Imagine that you have a string that breaks when you move it two lines above. That's not how a string should beha...
@final class FormattedStringViolation(ASTViolation):
""" Forbids to use ``f`` strings. Reasoning: ``f`` strings loses context too often and they are hard to lint. Imagine that you have a string that breaks when you move it two lines above. That's not how a string should behave. Also, they promote a bad practice: ...
.0 # Wrong: half = .5 ten_float = 10. .. versionadded:: 0.1.0 """ code = 304 error_template = 'Found partial float: {0}' @final class FormattedStringViolation(ASTViolation):
63
64
211
11
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
FormattedStringViolation
FormattedStringViolation
303
336
303
304
17ee69864554fdaf32d8540e8ad253fcd22dc24c
bigcode/the-stack
train
eb84fbeadab48c624006c913
train
class
@final class WrongHexNumberCaseViolation(TokenizeViolation): """ Forbids to use letters as hex numbers. Reasoning: One can write ``0xA`` and ``0xa`` which is inconsistent. This rule enforces upper-case letters in hex numbers. Solution: Use uppercase letters in hex numbers. ...
@final class WrongHexNumberCaseViolation(TokenizeViolation):
""" Forbids to use letters as hex numbers. Reasoning: One can write ``0xA`` and ``0xa`` which is inconsistent. This rule enforces upper-case letters in hex numbers. Solution: Use uppercase letters in hex numbers. Example:: # Correct: number = 0xABCDEF ...
-1 # Wrong: number = 1e+1 .. versionadded:: 0.12.0 """ error_template = 'Found exponent number with positive exponent: {0}' code = 340 @final class WrongHexNumberCaseViolation(TokenizeViolation):
64
64
133
13
50
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
WrongHexNumberCaseViolation
WrongHexNumberCaseViolation
1,589
1,614
1,589
1,590
7b528acf8856cedcad0447a4e975592512d096b1
bigcode/the-stack
train
5f54b47db518f1980f5619c3
train
class
@final class DottedRawImportViolation(ASTViolation): """ Forbids to use imports like ``import os.path``. Reasoning: There too many different ways to import something. We should pick one style and stick to it. We have decided to use the readable one. Solution: Refactor y...
@final class DottedRawImportViolation(ASTViolation):
""" Forbids to use imports like ``import os.path``. Reasoning: There too many different ways to import something. We should pick one style and stick to it. We have decided to use the readable one. Solution: Refactor your import statement. Example:: # Corre...
# Wrong: from .version import get_version from ..drivers import MySQLDriver .. versionadded:: 0.1.0 """ error_template = 'Found local folder import' code = 300 @final class DottedRawImportViolation(ASTViolation):
64
64
127
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
DottedRawImportViolation
DottedRawImportViolation
178
204
178
179
b5298a4e72df3196f11649097c6ef80e88c00ee6
bigcode/the-stack
train
3001a90b61add204ed41d977
train
class
@final class BadComplexNumberSuffixViolation(TokenizeViolation): """ Forbids to use uppercase complex number suffix. Reasoning: Numbers should be consistent. Solution: Use lowercase suffix for imaginary part. Example:: # Correct: complex_number = 1j # Wro...
@final class BadComplexNumberSuffixViolation(TokenizeViolation):
""" Forbids to use uppercase complex number suffix. Reasoning: Numbers should be consistent. Solution: Use lowercase suffix for imaginary part. Example:: # Correct: complex_number = 1j # Wrong: complex_number = 1J .. versionadded:: 0.12.0 ...
[r'\n', '\n'] # Wrong: escaped = '\\n' .. versionadded:: 0.12.0 """ error_template = 'Found implicit raw string: {0}' code = 342 @final class BadComplexNumberSuffixViolation(TokenizeViolation):
64
64
108
13
50
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
BadComplexNumberSuffixViolation
BadComplexNumberSuffixViolation
1,646
1,670
1,646
1,647
f852d14d193ea78d7eca9aed43a9ad45ab04f373
bigcode/the-stack
train
15b79d3ccd51335d746e6aa7
train
class
@final class MeaninglessNumberOperationViolation(ASTViolation): """ Forbids to use meaningless math operations with ``0`` and ``1``. Reasoning: Adding and substracting zero does not change the value. There's no need to do that. Multipling by zero is also redundant: it can be...
@final class MeaninglessNumberOperationViolation(ASTViolation):
""" Forbids to use meaningless math operations with ``0`` and ``1``. Reasoning: Adding and substracting zero does not change the value. There's no need to do that. Multipling by zero is also redundant: it can be replaced with explicit ``0`` assign. Multiplying and di...
:: # Correct: raise ZeroDivisionError() # Wrong: 1 / 0 .. versionadded:: 0.12.0 """ error_template = 'Found explicit zero division' code = 344 @final class MeaninglessNumberOperationViolation(ASTViolation):
64
64
192
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
MeaninglessNumberOperationViolation
MeaninglessNumberOperationViolation
1,703
1,735
1,703
1,704
dbac88f24a4c5b9a3066a42b74feaa24e6aeb7d1
bigcode/the-stack
train
13ee3d587489a5f6e392b82e
train
class
@final class PositiveExponentViolation(TokenizeViolation): """ Forbids to extra ``+`` signs in the exponent. Reasoning: Positive exponent is positive by default, there's no need to write an extra ``+`` sign. We enforce consistency with this rule. Solution: Remove meanin...
@final class PositiveExponentViolation(TokenizeViolation):
""" Forbids to extra ``+`` signs in the exponent. Reasoning: Positive exponent is positive by default, there's no need to write an extra ``+`` sign. We enforce consistency with this rule. Solution: Remove meaningless ``+`` sign from the exponent. Example:: ...
00001, 0o0002, 0x05, 10e010] .. versionadded:: 0.12.0 """ error_template = 'Found number with meaningless zeros: {0}' code = 339 @final class PositiveExponentViolation(TokenizeViolation):
64
64
143
11
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
PositiveExponentViolation
PositiveExponentViolation
1,560
1,586
1,560
1,561
d5683604730b39434f4ee9156834e4743b94a59c
bigcode/the-stack
train
77093c9c11b53c0e74296731
train
class
@final class AugmentedAssignPatternViolation(ASTViolation): """ Enforce using augmented assign pattern. Reasoning: ``a += b`` is short and correct version of ``a = a + b``. Why not using the short version? Example:: # Correct: a += b # Wrong: a = a + b...
@final class AugmentedAssignPatternViolation(ASTViolation):
""" Enforce using augmented assign pattern. Reasoning: ``a += b`` is short and correct version of ``a = a + b``. Why not using the short version? Example:: # Correct: a += b # Wrong: a = a + b .. versionadded:: 0.13.0 """ error_template ...
# Wrong: x[0:7] x[3:None] .. versionadded:: 0.13.0 """ error_template = 'Found redundant subscript slice: {0}' code = 349 @final class AugmentedAssignPatternViolation(ASTViolation):
64
64
108
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
AugmentedAssignPatternViolation
AugmentedAssignPatternViolation
1,858
1,880
1,858
1,859
0d2579d7012231ceab5b6b05dff5c85bb2a2b11e
bigcode/the-stack
train
bf6f9e5e78bc806ef3b4c6cb
train
class
@final class InconsistentReturnVariableViolation(ASTViolation): """ Forbids local variable that are only used in ``return`` statements. Reasoning: This is done for consistency and more readable source code. Solution: Return the expression itself, instead of creating a temporary variabl...
@final class InconsistentReturnVariableViolation(ASTViolation):
""" Forbids local variable that are only used in ``return`` statements. Reasoning: This is done for consistency and more readable source code. Solution: Return the expression itself, instead of creating a temporary variable. Example:: # Correct: def some_function(...
= ---3.33 number = ~~42 bar = not not foo .. versionadded:: 0.8.0 """ code = 330 error_template = 'Found unnecessary operator: {0}' @final class InconsistentReturnVariableViolation(ASTViolation):
63
64
142
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
InconsistentReturnVariableViolation
InconsistentReturnVariableViolation
1,257
1,287
1,257
1,258
8949e5797fa7729c61cdb88550b6f90edc68103e
bigcode/the-stack
train
69b4d0fe97ed9051a1925486
train
class
@final class MissingSpaceBetweenKeywordAndParenViolation(TokenizeViolation): """ Enforces to separate parenthesis from the keywords with spaces. Reasoning: Some people use ``return`` and ``yield`` keywords as functions. The same happened to good old ``print`` in Python2. Solution: ...
@final class MissingSpaceBetweenKeywordAndParenViolation(TokenizeViolation):
""" Enforces to separate parenthesis from the keywords with spaces. Reasoning: Some people use ``return`` and ``yield`` keywords as functions. The same happened to good old ``print`` in Python2. Solution: Insert space symbol between keyword and open paren. Example:: ...
else: do_something_else() # Correct: do_something() .. versionadded:: 0.3.0 """ error_template = 'Found compare between same variable' code = 312 @final class MissingSpaceBetweenKeywordAndParenViolation(TokenizeViolation):
64
64
182
15
48
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
MissingSpaceBetweenKeywordAndParenViolation
MissingSpaceBetweenKeywordAndParenViolation
565
597
565
566
d91d0373185a7f3acaea324e774d435c9b03774e
bigcode/the-stack
train
cd545f51cfac0495ef0a5a9d
train
class
@final class EmptyLineAfterCodingViolation(TokenizeViolation): """ Enforces to have an extra empty line after the ``coding`` comment. Reasoning: Since we use `flake8-coding <https://github.com/tk0miya/flake8-coding>`_ as a part of our linter we care about extra space after t...
@final class EmptyLineAfterCodingViolation(TokenizeViolation):
""" Enforces to have an extra empty line after the ``coding`` comment. Reasoning: Since we use `flake8-coding <https://github.com/tk0miya/flake8-coding>`_ as a part of our linter we care about extra space after this coding comment. This is done for pure consistency. ...
'abc' multiline = """ one two """ # Wrong: some_string = """abc""" some_bytes = b"""123""" Docstrings are ignored from this rule. You must use triple quotes strings for docstrings. .. versionadded:: 0.7.0 ''' error_template = 'Fou...
98
98
329
13
84
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
EmptyLineAfterCodingViolation
EmptyLineAfterCodingViolation
956
1,003
956
957
6037575b2fc3b183b032cccc74785219d6152d22
bigcode/the-stack
train
8830cb12f2651fd629fb954d
train
class
@final class OperationSignNegationViolation(ASTViolation): """ Forbids to have double minus operations. Reasoning: Having two operations is harder than having just one. Two negations are harder than one positive expression. Two negations equal to one positive expression. Pos...
@final class OperationSignNegationViolation(ASTViolation):
""" Forbids to have double minus operations. Reasoning: Having two operations is harder than having just one. Two negations are harder than one positive expression. Two negations equal to one positive expression. Positive and negative equal to one negative. Solution: ...
zero = some * 0 / 1 one = some ** 0 ** 1 .. versionadded:: 0.12.0 """ error_template = 'Found meaningless number operation' code = 345 @final class OperationSignNegationViolation(ASTViolation):
64
64
181
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
OperationSignNegationViolation
OperationSignNegationViolation
1,738
1,770
1,738
1,739
65c67c08eb98332ccea3d44df693df7da4936ee3
bigcode/the-stack
train
349d6c69cf45a40d055bf1bb
train
class
@final class MultilineFunctionAnnotationViolation(ASTViolation): """ Forbids to use multi-line function type annotations. Reasoning: Functions with multi-line type annotations are unreadable. Solution: Use type annotations that fit into a single line to annotate functions. If y...
@final class MultilineFunctionAnnotationViolation(ASTViolation):
""" Forbids to use multi-line function type annotations. Reasoning: Functions with multi-line type annotations are unreadable. Solution: Use type annotations that fit into a single line to annotate functions. If your annotation is too long, then use type aliases. Example::...
ize.TokenInfo]) -> TokenLines: ... We check round, square, and curly brackets. .. versionadded:: 0.6.0 """ error_template = 'Found bracket in wrong position' code = 319 @final class MultilineFunctionAnnotationViolation(ASTViolation):
64
64
157
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
MultilineFunctionAnnotationViolation
MultilineFunctionAnnotationViolation
857
888
857
858
bc7e0d418b18f573221ad89574f24a9be18af51f
bigcode/the-stack
train
ae0b179ce58d20504c5b322d
train
class
@final class ExtraIndentationViolation(TokenizeViolation): """ Forbids to use extra indentation. Reasoning: You can use extra indentation for lines of code. Python allows you to do that in case you will keep the indentation level equal for this specific node. But, that's ins...
@final class ExtraIndentationViolation(TokenizeViolation):
""" Forbids to use extra indentation. Reasoning: You can use extra indentation for lines of code. Python allows you to do that in case you will keep the indentation level equal for this specific node. But, that's insane! Solution: We should stick to 4 spaces for...
') Everything else is considered a violation. This rule checks: lists, sets, tuples, dicts, calls, functions, methods, and classes. .. versionadded:: 0.6.0 """ error_template = 'Found incorrect multi-line parameters' code = 317 @final class ExtraIndentationViolation(TokenizeViolation):
76
76
255
12
63
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ExtraIndentationViolation
ExtraIndentationViolation
763
801
763
764
de866084a8e9fa2c07462755389734f9f086fb6e
bigcode/the-stack
train
4f2873c28bb0a69bedd16fc7
train
class
@final class InconsistentYieldViolation(ASTViolation): """ Enforces to have consistent ``yield`` statements. Rules are: 1. if any ``yield`` has a value, all ``yield`` nodes should have a value This rule respects ``mypy`` style of placing ``yield`` statements. There should be no conflict with t...
@final class InconsistentYieldViolation(ASTViolation):
""" Enforces to have consistent ``yield`` statements. Rules are: 1. if any ``yield`` has a value, all ``yield`` nodes should have a value This rule respects ``mypy`` style of placing ``yield`` statements. There should be no conflict with these two checks. Reasoning: This is done f...
# Wrong: def function(): if some: return return 1 .. versionadded:: 0.7.0 """ error_template = 'Found inconsistent `return` statement' code = 324 @final class InconsistentYieldViolation(ASTViolation):
64
64
207
11
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
InconsistentYieldViolation
InconsistentYieldViolation
1,049
1,087
1,049
1,050
1aaf91858f03be8355de6722ca34b2d9fe54aa58
bigcode/the-stack
train
300aaee6e067f230f1771f11
train
class
@final class AdditionAssignmentOnListViolation(ASTViolation): """ Forbids usage of += with list arguments. Reasoning: ``+=`` works like ``extend()`` method. Why not just use ``extend()`` instead of ``+=`` to be consistent. Example:: # Correct: some_list.extend([1, 2, 3...
@final class AdditionAssignmentOnListViolation(ASTViolation):
""" Forbids usage of += with list arguments. Reasoning: ``+=`` works like ``extend()`` method. Why not just use ``extend()`` instead of ``+=`` to be consistent. Example:: # Correct: some_list.extend([1, 2, 3]) # Wrong: some_list += [1, 2, 3] .. ve...
# Wrong: from json import loads ... loads(content) .. versionadded:: 0.13.0 """ error_template = 'Found vague import that may cause confusion: {0}' code = 347 @final class AdditionAssignmentOnListViolation(ASTViolation):
64
64
128
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
AdditionAssignmentOnListViolation
AdditionAssignmentOnListViolation
1,807
1,829
1,807
1,808
d68da89b25c02bd2af3e5f6d4760e1358e17d415
bigcode/the-stack
train
d3c5da58629dceb50454523f
train
class
@final class UselessNodeViolation(ASTViolation): """ Forbids to use meaningless nodes. Reasoning: Some nodes might be completely useless. They will literally do nothing. Sometimes they are hard to find, because this situation can be caused by a recent refactoring or just by acedent....
@final class UselessNodeViolation(ASTViolation):
""" Forbids to use meaningless nodes. Reasoning: Some nodes might be completely useless. They will literally do nothing. Sometimes they are hard to find, because this situation can be caused by a recent refactoring or just by acedent. This might be also an overuse of syntax....
1, 2, 3]: print(number) continue .. versionadded:: 0.7.0 """ error_template = 'Found useless `continue` at the end of the loop' code = 327 @final class UselessNodeViolation(ASTViolation):
64
64
147
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
UselessNodeViolation
UselessNodeViolation
1,154
1,179
1,154
1,155
30af4da68112113c577e5c19efa6aa41bce001c5
bigcode/the-stack
train
7c093dc53c8194ffa49d8e12
train
class
@final class WrongLoopIterTypeViolation(ASTViolation): """ Forbids to use wrong ``for`` loop iter targets. We forbid to use: - Lists and list comprehensions - Sets and set comprehensions - Dicts and dict comprehensions - Generator expressions - Empty tuples Reasoning: Usin...
@final class WrongLoopIterTypeViolation(ASTViolation):
""" Forbids to use wrong ``for`` loop iter targets. We forbid to use: - Lists and list comprehensions - Sets and set comprehensions - Dicts and dict comprehensions - Generator expressions - Empty tuples Reasoning: Using lists, dicts, and sets do not make much sense. ...
Correct: if three < two < one: ... # Wrong: if one > two > three: ... .. versionadded:: 0.10.0 """ code = 334 error_template = 'Found reversed complex compare' @final class WrongLoopIterTypeViolation(ASTViolation):
68
68
228
12
56
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
WrongLoopIterTypeViolation
WrongLoopIterTypeViolation
1,383
1,422
1,383
1,384
1e56d23d3196aa5f70f19f251509b631d1a94b4d
bigcode/the-stack
train
0e8353c4571389d57dd04cef
train
class
@final class ExplicitStringConcatViolation(ASTViolation): """ Forbids explicit string concat in favour of ``.format`` method. However, we still allow multiline string concat as a way to write long strings that does not fit the 80-chars rule. Reasoning: When formating strings one must use `...
@final class ExplicitStringConcatViolation(ASTViolation):
""" Forbids explicit string concat in favour of ``.format`` method. However, we still allow multiline string concat as a way to write long strings that does not fit the 80-chars rule. Reasoning: When formating strings one must use ``.format`` and not any other formatting methods li...
Kim', 'Nick']: ... .. versionadded:: 0.10.0 .. versionchanged:: 0.12.0 """ code = 335 error_template = 'Found incorrect `for` loop iter type' @final class ExplicitStringConcatViolation(ASTViolation):
64
64
193
11
53
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ExplicitStringConcatViolation
ExplicitStringConcatViolation
1,425
1,454
1,425
1,426
dd30b68640bec54bbde04ac60bd3973ebdb2562e
bigcode/the-stack
train
2bfa332db29e11823eed5044
train
class
@final class MultipleInCompareViolation(ASTViolation): """ Forbids comparison where multiple ``in`` checks. Reasoning: Using multiple ``in`` is unreadable. Solution: Refactor your compare expression to use several ``and`` conditions or separate ``if`` statements in case it is a...
@final class MultipleInCompareViolation(ASTViolation):
""" Forbids comparison where multiple ``in`` checks. Reasoning: Using multiple ``in`` is unreadable. Solution: Refactor your compare expression to use several ``and`` conditions or separate ``if`` statements in case it is appropriate. Example:: # Correct: ...
1001 number_with_scientific_notation = 1.5E+10 .. versionadded:: 0.3.0 """ error_template = 'Found bad number suffix: {0}' code = 310 @final class MultipleInCompareViolation(ASTViolation):
64
64
175
11
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
MultipleInCompareViolation
MultipleInCompareViolation
501
529
501
502
2890390b66635b0f8dcc8f8155262808cc44b79a
bigcode/the-stack
train
c5cfef6ac91285fb00bd4b7e
train
class
@final class CompareOrderViolation(ASTViolation): """ Forbids comparison where argument doesn't come first. Reasoning: It is hard to read the code when you have to shuffle ordering of the arguments all the time. Bring consistency to the compare! Solution: Refactor your ...
@final class CompareOrderViolation(ASTViolation):
""" Forbids comparison where argument doesn't come first. Reasoning: It is hard to read the code when you have to shuffle ordering of the arguments all the time. Bring consistency to the compare! Solution: Refactor your compare expression, place the argument first. ...
: do_something() else: do_something_else() # Correct: do_something_else() .. versionadded:: 0.3.0 """ error_template = 'Found constant compare' code = 308 @final class CompareOrderViolation(ASTViolation):
64
64
140
10
53
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
CompareOrderViolation
CompareOrderViolation
433
460
433
434
426483de6ed026858826cc12b52be5f79438168e
bigcode/the-stack
train
1353b29905ac7fa866305955
train
class
@final class ConstantCompareViolation(ASTViolation): """ Forbids to have compares between two literals. Reasoning: When two constants are compared it is typically an indication of a mistake, since the Boolean value of the compare, will always be the same. Solution: Remo...
@final class ConstantCompareViolation(ASTViolation):
""" Forbids to have compares between two literals. Reasoning: When two constants are compared it is typically an indication of a mistake, since the Boolean value of the compare, will always be the same. Solution: Remove the constant compare and any associated dead code....
nodes = [node for node in html if node not in ('b', 'i')] .. versionadded:: 0.1.0 """ error_template = 'Found list comprehension with multiple `if`s' code = 307 @final class ConstantCompareViolation(ASTViolation):
64
64
146
10
53
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ConstantCompareViolation
ConstantCompareViolation
401
430
401
402
ec82e1955c346a267774c5f61ecd2d1109fb41d0
bigcode/the-stack
train
e85c90fee3be883b5f94e15f
train
class
@final class ConstantConditionViolation(ASTViolation): """ Forbids using ``if`` statements that use invalid conditionals. Reasoning: When invalid conditional arguments are used it is typically an indication of a mistake, since the value of the conditional result will always be the s...
@final class ConstantConditionViolation(ASTViolation):
""" Forbids using ``if`` statements that use invalid conditionals. Reasoning: When invalid conditional arguments are used it is typically an indication of a mistake, since the value of the conditional result will always be the same. Solution: Remove the conditional and ...
1 del (a, b) yield (1, 2, 3) .. versionadded:: 0.3.0 """ error_template = 'Found parens right after a keyword' code = 313 @final class ConstantConditionViolation(ASTViolation):
64
64
132
10
53
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ConstantConditionViolation
ConstantConditionViolation
600
626
600
601
0eb4e887d07b9ef8e5ad97ec6ab1157bb1b1cdb8
bigcode/the-stack
train
a7513ec2ce58fa059b85ba1b
train
class
@final class WrongMultilineStringViolation(TokenizeViolation): ''' Forbids to use triple quotes for singleline strings. Reasoning: String quotes should be consistent. Solution: Use single quotes for single-line strings. Triple quotes are only allowed for real multiline strings....
@final class WrongMultilineStringViolation(TokenizeViolation):
''' Forbids to use triple quotes for singleline strings. Reasoning: String quotes should be consistent. Solution: Use single quotes for single-line strings. Triple quotes are only allowed for real multiline strings. Example:: # Correct: single_line = 'abc'...
Wrong: some_string = R'/regex/' some_bytes = B'123' .. versionadded:: 0.6.0 """ error_template = 'Found uppercase string modifier: {0}' code = 321 @final class WrongMultilineStringViolation(TokenizeViolation):
64
64
158
13
50
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
WrongMultilineStringViolation
WrongMultilineStringViolation
920
953
920
921
fade249d2b7b5a6a2abeca55f82eca6a5da7f686
bigcode/the-stack
train
ce2232f0c4f3283e999740ea
train
class
@final class MultilineConditionsViolation(ASTViolation): """ Forbids multiline conditions. Reasoning: This way of writing conditions hides the inner complexity this line has. And it decreases readability of the code. Solution: Divide multiline conditions to some ``if`` conditio...
@final class MultilineConditionsViolation(ASTViolation):
""" Forbids multiline conditions. Reasoning: This way of writing conditions hides the inner complexity this line has. And it decreases readability of the code. Solution: Divide multiline conditions to some ``if`` condition. Or use variables. Example:: # Correct: ...
(some_data) # Wrong: x = 'a' + 'b: ' + some_data .. versionadded:: 0.12.0 """ code = 336 error_template = 'Found explicit string concat' @final class MultilineConditionsViolation(ASTViolation):
64
64
174
11
53
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
MultilineConditionsViolation
MultilineConditionsViolation
1,457
1,491
1,457
1,458
3e0e1006036931cfe6c66bf5e14ad847dce88cce
bigcode/the-stack
train
8471d526f265e94d82eb7c84
train
class
@final class UselessOperatorsViolation(ASTViolation): """ Forbids the use of unnecessary operators in your code. You can write: ``5.4`` and ``+5.4``. There's no need to use the second version. Similarly ``--5.4``, ``---5.4``, ``not not foo``, and ``~~42`` contain unnecessary operators. Reasoni...
@final class UselessOperatorsViolation(ASTViolation):
""" Forbids the use of unnecessary operators in your code. You can write: ``5.4`` and ``+5.4``. There's no need to use the second version. Similarly ``--5.4``, ``---5.4``, ``not not foo``, and ``~~42`` contain unnecessary operators. Reasoning: This is done for consistency reasons. ...
raise ValueError() # Wrong: try: ... except TypeError: raise .. versionadded:: 0.7.0 """ error_template = 'Found useless `except` case' code = 329 @final class UselessOperatorsViolation(ASTViolation):
65
65
217
12
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
UselessOperatorsViolation
UselessOperatorsViolation
1,219
1,254
1,219
1,220
057c2e1e3665690dac684e396431e3e2ff71ca37
bigcode/the-stack
train
e44ec97b29d25d0203c1bec9
train
class
@final class VagueImportViolation(ASTViolation): """ Forbids imports that may cause confusion outside of the module. Reasoning: See ``datetime.*`` in code? You know that it's from datetime. See ``BaseView`` in a Django project? You know where it is from. See ``loads``? It can be any...
@final class VagueImportViolation(ASTViolation):
""" Forbids imports that may cause confusion outside of the module. Reasoning: See ``datetime.*`` in code? You know that it's from datetime. See ``BaseView`` in a Django project? You know where it is from. See ``loads``? It can be anything: ``yaml``, ``toml``, ``json`` ... Exam...
Wrong: number = 3 - -1 number -= -6 number += -2 .. versionadded:: 0.12.0 """ error_template = 'Found wrong operation sign' code = 346 @final class VagueImportViolation(ASTViolation):
64
64
159
11
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
VagueImportViolation
VagueImportViolation
1,773
1,804
1,773
1,774
b89f07323063bed456652d7d1671734af4d13785
bigcode/the-stack
train
337bdda148ab03b131cb0715
train
class
@final class UnderscoredNumberViolation(TokenizeViolation): """ Forbids to use underscores (``_``) in numbers. Reasoning: It is possible to write ``1000`` in three different ways: ``1_000``, ``10_00``, and ``100_0``. And it would be still the same number. Count how many ways...
@final class UnderscoredNumberViolation(TokenizeViolation):
""" Forbids to use underscores (``_``) in numbers. Reasoning: It is possible to write ``1000`` in three different ways: ``1_000``, ``10_00``, and ``100_0``. And it would be still the same number. Count how many ways there are to write bigger numbers. Currently, it al...
file_contents = b'aabbcc' # Wrong: nickname = u'sobolevn' .. versionadded:: 0.1.0 """ code = 302 error_template = 'Found unicode string prefix: {0}' @final class UnderscoredNumberViolation(TokenizeViolation):
69
70
236
14
55
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
UnderscoredNumberViolation
UnderscoredNumberViolation
236
268
236
237
022338592eb97e196e8249889690dc10c542ad8e
bigcode/the-stack
train
c68be6a76d2339ff1d64eb13
train
class
@final class UnnecessaryLiteralsViolation(ASTViolation): """ Forbids the use of unnecessary literals in your code. Reasoning: We discourage using primitive calls to get default type values. There are better ways to get these values. Solution: Use direct default values of the gi...
@final class UnnecessaryLiteralsViolation(ASTViolation):
""" Forbids the use of unnecessary literals in your code. Reasoning: We discourage using primitive calls to get default type values. There are better ways to get these values. Solution: Use direct default values of the given type Example:: # Correct: defau...
:: # Correct: a += b # Wrong: a = a + b .. versionadded:: 0.13.0 """ error_template = 'Found usable augmented assign pattern' code = 350 @final class UnnecessaryLiteralsViolation(ASTViolation):
64
64
117
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
UnnecessaryLiteralsViolation
UnnecessaryLiteralsViolation
1,883
1,908
1,883
1,884
7b9b4512adb9e9d77c7b42c78f291145994fe6b5
bigcode/the-stack
train
616f988bf8d571c4c7bee748
train
class
@final class MultipleIfsInComprehensionViolation(ASTViolation): """ Forbids to have multiple ``if`` statements inside list comprehensions. Reasoning: It is very hard to read multiple ``if`` statements inside a list comprehension. Since it is even hard to tell all of them should pass...
@final class MultipleIfsInComprehensionViolation(ASTViolation):
""" Forbids to have multiple ``if`` statements inside list comprehensions. Reasoning: It is very hard to read multiple ``if`` statements inside a list comprehension. Since it is even hard to tell all of them should pass or fail. Solution: Use a single ``if`` statement i...
google.github.io/styleguide/pyguide.html#39-classes .. versionadded:: 0.1.0 """ error_template = 'Found class without a base class: {0}' code = 306 @final class MultipleIfsInComprehensionViolation(ASTViolation):
64
64
187
15
48
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
MultipleIfsInComprehensionViolation
MultipleIfsInComprehensionViolation
371
398
371
372
8357e0be6d16e0aef85fa70ab361029632300cf9
bigcode/the-stack
train
7bea7d387e114bd1df130315
train
class
@final class BadNumberSuffixViolation(TokenizeViolation): """ Forbids to use capital ``X``, ``O``, ``B``, and ``E`` in numbers. Reasoning: Octal, hex, binary and scientific notation suffixes could be written in two possible notations: lowercase and uppercase. Which brings confusion ...
@final class BadNumberSuffixViolation(TokenizeViolation):
""" Forbids to use capital ``X``, ``O``, ``B``, and ``E`` in numbers. Reasoning: Octal, hex, binary and scientific notation suffixes could be written in two possible notations: lowercase and uppercase. Which brings confusion and decreases code consistency and readability. We...
:: # Correct: if some_x > 3: if 3 < some_x < 10: # Wrong: if 3 < some_x: .. versionadded:: 0.3.0 """ error_template = 'Found reversed compare order' code = 309 @final class BadNumberSuffixViolation(TokenizeViolation):
78
78
262
12
65
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
BadNumberSuffixViolation
BadNumberSuffixViolation
463
498
463
464
d4d362e81006ce77705cfc47f93679289b69f2dc
bigcode/the-stack
train
5d880acf0b1ff239a45e0ed4
train
class
@final class UselessContinueViolation(ASTViolation): """ Forbids to use meaningless ``continue`` node in loops. Reasoning: Placing this keyword in the end of any loop won't make any difference to your code. And we prefer not to have meaningless constructs in our code. Solution:...
@final class UselessContinueViolation(ASTViolation):
""" Forbids to use meaningless ``continue`` node in loops. Reasoning: Placing this keyword in the end of any loop won't make any difference to your code. And we prefer not to have meaningless constructs in our code. Solution: Remove useless ``continue`` node from the lo...
= 'first' + 'second' # Wrong: text = 'first' 'second' .. versionadded:: 0.7.0 """ error_template = 'Found implicit string concatenation' code = 326 @final class UselessContinueViolation(ASTViolation):
64
64
176
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
UselessContinueViolation
UselessContinueViolation
1,120
1,151
1,120
1,121
022d80d844452218b7e822588b6f19ef35f64bd7
bigcode/the-stack
train
6475d2348e18fe00ca8d77f5
train
class
@final class UselessExceptCaseViolation(ASTViolation): """ Forbids to use meaningless ``except`` cases. Reasoning: Using ``except`` cases that just reraise the same exception is error-prone. You can increase your stacktrace, silence some potential exceptions, and screw things up. ...
@final class UselessExceptCaseViolation(ASTViolation):
""" Forbids to use meaningless ``except`` cases. Reasoning: Using ``except`` cases that just reraise the same exception is error-prone. You can increase your stacktrace, silence some potential exceptions, and screw things up. It also does not make any sense to do so. So...
# Wrong: for number in [1, 2, 3]: break .. versionadded:: 0.7.0 """ error_template = 'Found useless node: {0}' code = 328 @final class UselessExceptCaseViolation(ASTViolation):
64
64
174
13
50
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
UselessExceptCaseViolation
UselessExceptCaseViolation
1,182
1,216
1,182
1,183
815dd55faabc7f98a8156b7895ff133983786553
bigcode/the-stack
train
17f3aa12d5f081c96f695c33
train
class
@final class UnicodeStringViolation(TokenizeViolation): """ Forbids to use ``u`` string prefix. Reasoning: We do not need this prefix since ``python2``. But, it is still possible to find it inside the codebase. Solution: Remove this prefix. Example:: # Correct: ...
@final class UnicodeStringViolation(TokenizeViolation):
""" Forbids to use ``u`` string prefix. Reasoning: We do not need this prefix since ``python2``. But, it is still possible to find it inside the codebase. Solution: Remove this prefix. Example:: # Correct: nickname = 'sobolevn' file_contents = b'aa...
:: # Correct: from os import path # Wrong: import os.path .. versionadded:: 0.1.0 """ error_template = 'Found dotted raw import: {0}' code = 301 @final class UnicodeStringViolation(TokenizeViolation):
64
64
135
11
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
UnicodeStringViolation
UnicodeStringViolation
207
233
207
208
b84f7917fbe40697dad3610f37d9ed669c906b65
bigcode/the-stack
train
8d4609fc0749270985fbd2ec
train
class
@final class PartialFloatViolation(TokenizeViolation): """ Forbids to use partial floats like ``.05`` or ``23.``. Reasoning: Partial numbers are hard to read and they can be confused with other numbers. For example, it is really easy to confuse ``0.5`` and ``.05`` when reading ...
@final class PartialFloatViolation(TokenizeViolation):
""" Forbids to use partial floats like ``.05`` or ``23.``. Reasoning: Partial numbers are hard to read and they can be confused with other numbers. For example, it is really easy to confuse ``0.5`` and ``.05`` when reading through the source code. Solution: Use ...
8_83_134_43 million = 100_00_00 .. versionadded:: 0.1.0 """ code = 303 error_template = 'Found underscored number: {0}' @final class PartialFloatViolation(TokenizeViolation):
63
64
169
11
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
PartialFloatViolation
PartialFloatViolation
271
300
271
272
f4c28ab755160f0c23d13a7d7e594c2ea39865a0
bigcode/the-stack
train
d3173ff9a9ce502276d572d4
train
class
@final class ImplicitTernaryViolation(ASTViolation): """ Forbids to have implicit ternary expressions. Reasoning: This is done for consistency and readability reasons. We believe that explicit ternary is better for readability. This also allows you to identify hidden conditionals in...
@final class ImplicitTernaryViolation(ASTViolation):
""" Forbids to have implicit ternary expressions. Reasoning: This is done for consistency and readability reasons. We believe that explicit ternary is better for readability. This also allows you to identify hidden conditionals in your code. Solution: Refactor to use ex...
= 1 return some_value .. versionadded:: 0.9.0 """ error_template = ( 'Found local variable that are only used in `return` statements' ) code = 331 @final class ImplicitTernaryViolation(ASTViolation):
64
64
146
13
50
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ImplicitTernaryViolation
ImplicitTernaryViolation
1,290
1,316
1,290
1,291
d1c0d98ece7271f73c8dfc8d9ee18e379ec2fac4
bigcode/the-stack
train
7b306572ce2d367b71db933e
train
class
@final class ReversedComplexCompareViolation(ASTViolation): """ Forbids to have reversed order complex compare expressions. Reasoning: Compares where comparators start from the lowest element are easier to read than one that start from the biggest one. It is also possible to write t...
@final class ReversedComplexCompareViolation(ASTViolation):
""" Forbids to have reversed order complex compare expressions. Reasoning: Compares where comparators start from the lowest element are easier to read than one that start from the biggest one. It is also possible to write the same expression in two separate way, which is inc...
two < one: ... # Wrong: if one > two and two > three: ... .. versionadded:: 0.10.0 """ code = 333 error_template = 'Found implicit complex compare' @final class ReversedComplexCompareViolation(ASTViolation):
64
64
165
12
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ReversedComplexCompareViolation
ReversedComplexCompareViolation
1,350
1,380
1,350
1,351
b29a2d423ccbbf24c2d8443d57c6ba38e0378043
bigcode/the-stack
train
a9a80dd59f864d8694d8fda6
train
class
@final class MultipleContextManagerAssignmentsViolation(ASTViolation): """ Forbids multiple assignment targets for context managers. Reasoning: It is hard to distinguish whether ``as`` should unpack into tuple or we are just using two context managers. Solution: Use several con...
@final class MultipleContextManagerAssignmentsViolation(ASTViolation):
""" Forbids multiple assignment targets for context managers. Reasoning: It is hard to distinguish whether ``as`` should unpack into tuple or we are just using two context managers. Solution: Use several context managers. Or explicit brackets. Example:: # Correct:...
class SomeClassName(FirstParentClass, SecondParentClass, object): ... .. versionadded:: 0.3.0 """ error_template = 'Founded extra `object` in parent classes list' code = 315 @final class MultipleContextManagerAssignmentsViolation(ASTViolation):
64
64
149
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
MultipleContextManagerAssignmentsViolation
MultipleContextManagerAssignmentsViolation
660
691
660
661
8b06dba7427f40b269bfef89f54c1110ff9d7589
bigcode/the-stack
train
024faf5941502654c13d3c93
train
class
@final class ZeroDivisionViolation(ASTViolation): """ Forbids to explicitly divide by zero. Reasoning: This will just throw ``ZeroDivisionError`` in case that's what you need: just throw it. No need to use undefined meth behaviours. Or it might be just a typo / mistake, then...
@final class ZeroDivisionViolation(ASTViolation):
""" Forbids to explicitly divide by zero. Reasoning: This will just throw ``ZeroDivisionError`` in case that's what you need: just throw it. No need to use undefined meth behaviours. Or it might be just a typo / mistake, then fix it. Solution: Use ``ZeroDivision...
complex_number = 1j # Wrong: complex_number = 1J .. versionadded:: 0.12.0 """ error_template = 'Found wrong complex number suffix: {0}' code = 343 @final class ZeroDivisionViolation(ASTViolation):
64
64
147
10
53
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
ZeroDivisionViolation
ZeroDivisionViolation
1,673
1,700
1,673
1,674
d9aafd5ef2313bef1d20c0d36a603a90e9663664
bigcode/the-stack
train
022509f76303870f31a634fc
train
class
@final class WrongBracketPositionViolation(TokenizeViolation): """ Forbids to have brackets in the wrong position. Reasoning: You can do bizzare things with bracket positioning in python. We require all brackets to be consistent. Solution: Place bracket on the same line, in cas...
@final class WrongBracketPositionViolation(TokenizeViolation):
""" Forbids to have brackets in the wrong position. Reasoning: You can do bizzare things with bracket positioning in python. We require all brackets to be consistent. Solution: Place bracket on the same line, in case of a single line expression. Or place the bracket on ...
ley/isort#multi-line-output-modes https://github.com/wemake-services/wemake-python-styleguide/blob/master/styles/isort.toml .. versionadded:: 0.6.0 """ error_template = 'Found extra indentation' code = 318 @final class WrongBracketPositionViolation(TokenizeViolation):
72
72
243
12
59
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
WrongBracketPositionViolation
WrongBracketPositionViolation
804
854
804
805
4db85525496f9f446aa1efc56a8c2f8d41462cf7
bigcode/the-stack
train
4534d49db25fb852b7bb0e32
train
class
@final class InconsistentReturnViolation(ASTViolation): """ Enforces to have consistent ``return`` statements. Rules are: 1. if any ``return`` has a value, all ``return`` nodes should have a value 2. do not place ``return`` without value at the end of a function This rule respects ``mypy`` sty...
@final class InconsistentReturnViolation(ASTViolation):
""" Enforces to have consistent ``return`` statements. Rules are: 1. if any ``return`` has a value, all ``return`` nodes should have a value 2. do not place ``return`` without value at the end of a function This rule respects ``mypy`` style of placing ``return`` statements. There should be...
# Wrong: # coding: utf-8 SOME_VAR = 1 .. versionadded:: 0.7.0 """ error_template = ( 'Found missing empty line between `coding` magic comment and code' ) code = 323 @final class InconsistentReturnViolation(ASTViolation):
71
71
237
11
59
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
InconsistentReturnViolation
InconsistentReturnViolation
1,006
1,046
1,006
1,007
87601f7c502847d3d85211154372a738e2d1f006
bigcode/the-stack
train
0fa767ac5ae1538e19328e63
train
class
@final class MultilineLoopViolation(ASTViolation): """ Forbids multiline loops. Reasoning: It decreased the readability of the code. Solution: Use single line loops and create new variables in case you need to fit too many logic inside the loop definition. Example:: ...
@final class MultilineLoopViolation(ASTViolation):
""" Forbids multiline loops. Reasoning: It decreased the readability of the code. Solution: Use single line loops and create new variables in case you need to fit too many logic inside the loop definition. Example:: # Correct for num in some_function(arg1...
type Example:: # Correct: default = 0 # Wrong: default = int() .. versionadded:: 0.13.0 """ error_template = 'Found unnecessary literals.' code = 351 @final class MultilineLoopViolation(ASTViolation):
64
64
135
11
52
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
MultilineLoopViolation
MultilineLoopViolation
1,911
1,942
1,911
1,912
0ce8a368d31e31f157b6faabd2b5ab916e4c8a75
bigcode/the-stack
train
dbff6f6121d2c22d99ab95a5
train
class
@final class UppercaseStringModifierViolation(TokenizeViolation): """ Forbids to use uppercase string modifiers. Reasoning: String modifiers should be consistent. Solution: Use lowercase modifiers. Example:: # Correct: some_string = r'/regex/' some_bytes =...
@final class UppercaseStringModifierViolation(TokenizeViolation):
""" Forbids to use uppercase string modifiers. Reasoning: String modifiers should be consistent. Solution: Use lowercase modifiers. Example:: # Correct: some_string = r'/regex/' some_bytes = b'123' # Wrong: some_string = R'/regex/' ...
[ int, ]: ... This rule checks argument and return type annotations. .. versionadded:: 0.6.0 """ error_template = 'Found multi-line function type annotation' code = 320 @final class UppercaseStringModifierViolation(TokenizeViolation):
64
64
120
13
50
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
UppercaseStringModifierViolation
UppercaseStringModifierViolation
891
917
891
892
2f76418b51ae4c72e77fca129c8aa4c7079c46da
bigcode/the-stack
train
90ebd4d3f33d3b482df78fa7
train
class
@final class RedundantSubscriptViolation(ASTViolation): """ Forbids the use of redundant components in a subscript's slice. Reasoning: We do it for consistency reasons. Example:: # Correct: array[:7] array[3:] # Wrong: x[0:7] x[3:None] .. ...
@final class RedundantSubscriptViolation(ASTViolation):
""" Forbids the use of redundant components in a subscript's slice. Reasoning: We do it for consistency reasons. Example:: # Correct: array[:7] array[3:] # Wrong: x[0:7] x[3:None] .. versionadded:: 0.13.0 """ error_template = 'Fo...
3]) # Wrong: some_list += [1, 2, 3] .. versionadded:: 0.13.0 """ error_template = 'Found addition assignment with list argument' code = 348 @final class RedundantSubscriptViolation(ASTViolation):
64
64
111
12
51
ulturt/wemake-python-styleguide
wemake_python_styleguide/violations/consistency.py
Python
RedundantSubscriptViolation
RedundantSubscriptViolation
1,832
1,855
1,832
1,833
cadab3829b3de820bb77eca7f38a55410de9696c
bigcode/the-stack
train