Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
AutodetectorTests.test_arrange_for_graph | (self) | Tests auto-naming of migrations for graph matching. | Tests auto-naming of migrations for graph matching. | def test_arrange_for_graph(self):
"Tests auto-naming of migrations for graph matching."
# Make a fake graph
graph = MigrationGraph()
graph.add_node(("testapp", "0001_initial"), None)
graph.add_node(("testapp", "0002_foobar"), None)
graph.add_node(("otherapp", "0001_initia... | [
"def",
"test_arrange_for_graph",
"(",
"self",
")",
":",
"# Make a fake graph",
"graph",
"=",
"MigrationGraph",
"(",
")",
"graph",
".",
"add_node",
"(",
"(",
"\"testapp\"",
",",
"\"0001_initial\"",
")",
",",
"None",
")",
"graph",
".",
"add_node",
"(",
"(",
"\... | [
157,
4
] | [
177,
93
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_trim_apps | (self) | Tests that trim does not remove dependencies but does remove unwanted apps | Tests that trim does not remove dependencies but does remove unwanted apps | def test_trim_apps(self):
"Tests that trim does not remove dependencies but does remove unwanted apps"
# Use project state to make a new migration change set
before = self.make_project_state([])
after = self.make_project_state([self.author_empty, self.other_pony, self.other_stable, self.... | [
"def",
"test_trim_apps",
"(",
"self",
")",
":",
"# Use project state to make a new migration change set",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
... | [
179,
4
] | [
194,
45
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_custom_migration_name | (self) | Tests custom naming of migrations for graph matching. | Tests custom naming of migrations for graph matching. | def test_custom_migration_name(self):
"Tests custom naming of migrations for graph matching."
# Make a fake graph
graph = MigrationGraph()
graph.add_node(("testapp", "0001_initial"), None)
graph.add_node(("testapp", "0002_foobar"), None)
graph.add_node(("otherapp", "0001_... | [
"def",
"test_custom_migration_name",
"(",
"self",
")",
":",
"# Make a fake graph",
"graph",
"=",
"MigrationGraph",
"(",
")",
"graph",
".",
"add_node",
"(",
"(",
"\"testapp\"",
",",
"\"0001_initial\"",
")",
",",
"None",
")",
"graph",
".",
"add_node",
"(",
"(",
... | [
196,
4
] | [
219,
93
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_new_model | (self) | Tests autodetection of new models | Tests autodetection of new models | def test_new_model(self):
"Tests autodetection of new models"
# Make state
before = self.make_project_state([])
after = self.make_project_state([self.author_empty])
autodetector = MigrationAutodetector(before, after)
changes = autodetector._detect_changes()
# Righ... | [
"def",
"test_new_model",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
"]",
")",
"autodetector",
"=",
"Mi... | [
221,
4
] | [
236,
47
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_old_model | (self) | Tests deletion of old models | Tests deletion of old models | def test_old_model(self):
"Tests deletion of old models"
# Make state
before = self.make_project_state([self.author_empty])
after = self.make_project_state([])
autodetector = MigrationAutodetector(before, after)
changes = autodetector._detect_changes()
# Right num... | [
"def",
"test_old_model",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"autodetector",
"=",
"Mi... | [
238,
4
] | [
253,
47
] | python | en | ['en', 'da', 'en'] | True |
AutodetectorTests.test_add_field | (self) | Tests autodetection of new fields | Tests autodetection of new fields | def test_add_field(self):
"Tests autodetection of new fields"
# Make state
before = self.make_project_state([self.author_empty])
after = self.make_project_state([self.author_name])
autodetector = MigrationAutodetector(before, after)
changes = autodetector._detect_changes(... | [
"def",
"test_add_field",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name",
"]",
"... | [
255,
4
] | [
270,
45
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_remove_field | (self) | Tests autodetection of removed fields | Tests autodetection of removed fields | def test_remove_field(self):
"Tests autodetection of removed fields"
# Make state
before = self.make_project_state([self.author_name])
after = self.make_project_state([self.author_empty])
autodetector = MigrationAutodetector(before, after)
changes = autodetector._detect_c... | [
"def",
"test_remove_field",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
"]",
... | [
272,
4
] | [
287,
45
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_alter_field | (self) | Tests autodetection of new fields | Tests autodetection of new fields | def test_alter_field(self):
"Tests autodetection of new fields"
# Make state
before = self.make_project_state([self.author_name])
after = self.make_project_state([self.author_name_longer])
autodetector = MigrationAutodetector(before, after)
changes = autodetector._detect_... | [
"def",
"test_alter_field",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name_longer",
... | [
289,
4
] | [
305,
48
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_alter_field_to_not_null_with_default | (self) | #23609 - Tests autodetection of nullable to non-nullable alterations | #23609 - Tests autodetection of nullable to non-nullable alterations | def test_alter_field_to_not_null_with_default(self):
"#23609 - Tests autodetection of nullable to non-nullable alterations"
class CustomQuestioner(MigrationQuestioner):
def ask_not_null_alteration(self, field_name, model_name):
raise Exception("Should not have prompted for no... | [
"def",
"test_alter_field_to_not_null_with_default",
"(",
"self",
")",
":",
"class",
"CustomQuestioner",
"(",
"MigrationQuestioner",
")",
":",
"def",
"ask_not_null_alteration",
"(",
"self",
",",
"field_name",
",",
"model_name",
")",
":",
"raise",
"Exception",
"(",
"\... | [
307,
4
] | [
328,
62
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_alter_field_to_not_null_without_default | (self) | #23609 - Tests autodetection of nullable to non-nullable alterations | #23609 - Tests autodetection of nullable to non-nullable alterations | def test_alter_field_to_not_null_without_default(self):
"#23609 - Tests autodetection of nullable to non-nullable alterations"
class CustomQuestioner(MigrationQuestioner):
def ask_not_null_alteration(self, field_name, model_name):
# Ignore for now, and let me handle existing ... | [
"def",
"test_alter_field_to_not_null_without_default",
"(",
"self",
")",
":",
"class",
"CustomQuestioner",
"(",
"MigrationQuestioner",
")",
":",
"def",
"ask_not_null_alteration",
"(",
"self",
",",
"field_name",
",",
"model_name",
")",
":",
"# Ignore for now, and let me ha... | [
330,
4
] | [
354,
64
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_alter_field_to_not_null_oneoff_default | (self) | #23609 - Tests autodetection of nullable to non-nullable alterations | #23609 - Tests autodetection of nullable to non-nullable alterations | def test_alter_field_to_not_null_oneoff_default(self):
"#23609 - Tests autodetection of nullable to non-nullable alterations"
class CustomQuestioner(MigrationQuestioner):
def ask_not_null_alteration(self, field_name, model_name):
# Provide a one-off default now (will be set o... | [
"def",
"test_alter_field_to_not_null_oneoff_default",
"(",
"self",
")",
":",
"class",
"CustomQuestioner",
"(",
"MigrationQuestioner",
")",
":",
"def",
"ask_not_null_alteration",
"(",
"self",
",",
"field_name",
",",
"model_name",
")",
":",
"# Provide a one-off default now ... | [
356,
4
] | [
378,
59
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_rename_field | (self) | Tests autodetection of renamed fields | Tests autodetection of renamed fields | def test_rename_field(self):
"Tests autodetection of renamed fields"
# Make state
before = self.make_project_state([self.author_name])
after = self.make_project_state([self.author_name_renamed])
autodetector = MigrationAutodetector(before, after, MigrationQuestioner({"ask_rename"... | [
"def",
"test_rename_field",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name_renamed",
... | [
380,
4
] | [
390,
99
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_rename_model | (self) | Tests autodetection of renamed models | Tests autodetection of renamed models | def test_rename_model(self):
"Tests autodetection of renamed models"
# Make state
before = self.make_project_state([self.author_with_book, self.book])
after = self.make_project_state([self.author_renamed_with_book, self.book_with_author_renamed])
autodetector = MigrationAutodetec... | [
"def",
"test_rename_model",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_book",
",",
"self",
".",
"book",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"... | [
392,
4
] | [
412,
59
] | python | en | ['en', 'da', 'en'] | True |
AutodetectorTests.test_rename_model_with_renamed_rel_field | (self) |
Tests autodetection of renamed models while simultaneously renaming one
of the fields that relate to the renamed model.
|
Tests autodetection of renamed models while simultaneously renaming one
of the fields that relate to the renamed model.
| def test_rename_model_with_renamed_rel_field(self):
"""
Tests autodetection of renamed models while simultaneously renaming one
of the fields that relate to the renamed model.
"""
# Make state
before = self.make_project_state([self.author_with_book, self.book])
af... | [
"def",
"test_rename_model_with_renamed_rel_field",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_book",
",",
"self",
".",
"book",
"]",
")",
"after",
"=",
"self",
".",
"make_project_st... | [
414,
4
] | [
444,
51
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_fk_dependency | (self) | Tests that having a ForeignKey automatically adds a dependency | Tests that having a ForeignKey automatically adds a dependency | def test_fk_dependency(self):
"Tests that having a ForeignKey automatically adds a dependency"
# Make state
# Note that testapp (author) has no dependencies,
# otherapp (book) depends on testapp (author),
# thirdapp (edition) depends on otherapp (book)
before = self.make_... | [
"def",
"test_fk_dependency",
"(",
"self",
")",
":",
"# Make state",
"# Note that testapp (author) has no dependencies,",
"# otherapp (book) depends on testapp (author),",
"# thirdapp (edition) depends on otherapp (book)",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
... | [
446,
4
] | [
477,
75
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_proxy_fk_dependency | (self) | Tests that FK dependencies still work on proxy models | Tests that FK dependencies still work on proxy models | def test_proxy_fk_dependency(self):
"Tests that FK dependencies still work on proxy models"
# Make state
# Note that testapp (author) has no dependencies,
# otherapp (book) depends on testapp (authorproxy)
before = self.make_project_state([])
after = self.make_project_sta... | [
"def",
"test_proxy_fk_dependency",
"(",
"self",
")",
":",
"# Make state",
"# Note that testapp (author) has no dependencies,",
"# otherapp (book) depends on testapp (authorproxy)",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
"... | [
479,
4
] | [
500,
86
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_same_app_no_fk_dependency | (self) |
Tests that a migration with a FK between two models of the same app
does not have a dependency to itself.
|
Tests that a migration with a FK between two models of the same app
does not have a dependency to itself.
| def test_same_app_no_fk_dependency(self):
"""
Tests that a migration with a FK between two models of the same app
does not have a dependency to itself.
"""
# Make state
before = self.make_project_state([])
after = self.make_project_state([self.author_with_publishe... | [
"def",
"test_same_app_no_fk_dependency",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_publisher",
",",
"self",
... | [
502,
4
] | [
519,
64
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_circular_fk_dependency | (self) |
Tests that having a circular ForeignKey dependency automatically
resolves the situation into 2 migrations on one side and 1 on the other.
|
Tests that having a circular ForeignKey dependency automatically
resolves the situation into 2 migrations on one side and 1 on the other.
| def test_circular_fk_dependency(self):
"""
Tests that having a circular ForeignKey dependency automatically
resolves the situation into 2 migrations on one side and 1 on the other.
"""
# Make state
before = self.make_project_state([])
after = self.make_project_sta... | [
"def",
"test_circular_fk_dependency",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_book",
",",
"self",
".",
"... | [
521,
4
] | [
543,
115
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_same_app_circular_fk_dependency | (self) |
Tests that a migration with a FK between two models of the same app
does not have a dependency to itself.
|
Tests that a migration with a FK between two models of the same app
does not have a dependency to itself.
| def test_same_app_circular_fk_dependency(self):
"""
Tests that a migration with a FK between two models of the same app
does not have a dependency to itself.
"""
# Make state
before = self.make_project_state([])
after = self.make_project_state([self.author_with_pu... | [
"def",
"test_same_app_circular_fk_dependency",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_publisher",
",",
"sel... | [
545,
4
] | [
562,
64
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_same_app_circular_fk_dependency_and_unique_together | (self) |
Tests that a migration with circular FK dependency does not try to
create unique together constraint before creating all required fields first.
See ticket #22275.
|
Tests that a migration with circular FK dependency does not try to
create unique together constraint before creating all required fields first.
See ticket #22275.
| def test_same_app_circular_fk_dependency_and_unique_together(self):
"""
Tests that a migration with circular FK dependency does not try to
create unique together constraint before creating all required fields first.
See ticket #22275.
"""
# Make state
before = sel... | [
"def",
"test_same_app_circular_fk_dependency_and_unique_together",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"knight",
",",
... | [
564,
4
] | [
581,
61
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_unique_together | (self) | Tests unique_together detection | Tests unique_together detection | def test_unique_together(self):
"Tests unique_together detection"
# Make state
before = self.make_project_state([self.author_empty, self.book])
after = self.make_project_state([self.author_empty, self.book_unique])
autodetector = MigrationAutodetector(before, after)
chang... | [
"def",
"test_unique_together",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
",",
"self",
".",
"book",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"s... | [
583,
4
] | [
599,
71
] | python | da | ['fr', 'da', 'en'] | False |
AutodetectorTests.test_unique_together_no_changes | (self) | Tests that unique_togther doesn't generate a migration if no changes have been made | Tests that unique_togther doesn't generate a migration if no changes have been made | def test_unique_together_no_changes(self):
"Tests that unique_togther doesn't generate a migration if no changes have been made"
# Make state
before = self.make_project_state([self.author_empty, self.book_unique])
after = self.make_project_state([self.author_empty, self.book_unique])
... | [
"def",
"test_unique_together_no_changes",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
",",
"self",
".",
"book_unique",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
... | [
601,
4
] | [
609,
41
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_empty_foo_together | (self) | #23452 - Empty unique/index_togther shouldn't generate a migration. | #23452 - Empty unique/index_togther shouldn't generate a migration. | def test_empty_foo_together(self):
"#23452 - Empty unique/index_togther shouldn't generate a migration."
# Explicitly testing for not specified, since this is the case after
# a CreateModel operation w/o any definition on the original model
model_state_not_secified = ModelState("a", "mod... | [
"def",
"test_empty_foo_together",
"(",
"self",
")",
":",
"# Explicitly testing for not specified, since this is the case after",
"# a CreateModel operation w/o any definition on the original model",
"model_state_not_secified",
"=",
"ModelState",
"(",
"\"a\"",
",",
"\"model\"",
",",
"... | [
611,
4
] | [
653,
20
] | python | en | ['en', 'ca', 'en'] | True |
AutodetectorTests.test_unique_together_ordering | (self) | Tests that unique_together also triggers on ordering changes | Tests that unique_together also triggers on ordering changes | def test_unique_together_ordering(self):
"Tests that unique_together also triggers on ordering changes"
# Make state
before = self.make_project_state([self.author_empty, self.book_unique])
after = self.make_project_state([self.author_empty, self.book_unique_2])
autodetector = Mig... | [
"def",
"test_unique_together_ordering",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
",",
"self",
".",
"book_unique",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
... | [
655,
4
] | [
671,
71
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_add_field_and_unique_together | (self) | Tests that added fields will be created before using them in unique together | Tests that added fields will be created before using them in unique together | def test_add_field_and_unique_together(self):
"Tests that added fields will be created before using them in unique together"
before = self.make_project_state([self.author_empty, self.book])
after = self.make_project_state([self.author_empty, self.book_unique_3])
autodetector = MigrationA... | [
"def",
"test_add_field_and_unique_together",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
",",
"self",
".",
"book",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self"... | [
673,
4
] | [
689,
74
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_proxy | (self) | Tests that the autodetector correctly deals with proxy models | Tests that the autodetector correctly deals with proxy models | def test_proxy(self):
"Tests that the autodetector correctly deals with proxy models"
# First, we test adding a proxy model
before = self.make_project_state([self.author_empty])
after = self.make_project_state([self.author_empty, self.author_proxy])
autodetector = MigrationAutode... | [
"def",
"test_proxy",
"(",
"self",
")",
":",
"# First, we test adding a proxy model",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"aut... | [
729,
4
] | [
751,
96
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_proxy_custom_pk | (self) | #23415 - The autodetector must correctly deal with custom FK on proxy models. | #23415 - The autodetector must correctly deal with custom FK on proxy models. | def test_proxy_custom_pk(self):
"#23415 - The autodetector must correctly deal with custom FK on proxy models."
# First, we test the default pk field name
before = self.make_project_state([])
after = self.make_project_state([self.author_empty, self.author_proxy_third, self.book_proxy_fk]... | [
"def",
"test_proxy_custom_pk",
"(",
"self",
")",
":",
"# First, we test the default pk field name",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
",",
... | [
753,
4
] | [
769,
102
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_unmanaged | (self) | Tests that the autodetector correctly deals with managed models | Tests that the autodetector correctly deals with managed models | def test_unmanaged(self):
"Tests that the autodetector correctly deals with managed models"
# First, we test adding an unmanaged model
before = self.make_project_state([self.author_empty])
after = self.make_project_state([self.author_empty, self.author_unmanaged])
autodetector = ... | [
"def",
"test_unmanaged",
"(",
"self",
")",
":",
"# First, we test adding an unmanaged model",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".... | [
771,
4
] | [
792,
88
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_unmanaged_custom_pk | (self) | #23415 - The autodetector must correctly deal with custom FK on unmanaged models. | #23415 - The autodetector must correctly deal with custom FK on unmanaged models. | def test_unmanaged_custom_pk(self):
"#23415 - The autodetector must correctly deal with custom FK on unmanaged models."
# First, we test the default pk field name
before = self.make_project_state([])
after = self.make_project_state([self.author_unmanaged_default_pk, self.book])
a... | [
"def",
"test_unmanaged_custom_pk",
"(",
"self",
")",
":",
"# First, we test the default pk field name",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_unmanaged_de... | [
794,
4
] | [
810,
102
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_add_field_with_default | (self) |
Adding a field with a default should work (#22030).
|
Adding a field with a default should work (#22030).
| def test_add_field_with_default(self):
"""
Adding a field with a default should work (#22030).
"""
# Make state
before = self.make_project_state([self.author_empty])
after = self.make_project_state([self.author_name_default])
autodetector = MigrationAutodetector(b... | [
"def",
"test_add_field_with_default",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name... | [
824,
4
] | [
841,
45
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_custom_deconstructable | (self) |
Two instances which deconstruct to the same value aren't considered a
change.
|
Two instances which deconstruct to the same value aren't considered a
change.
| def test_custom_deconstructable(self):
"""
Two instances which deconstruct to the same value aren't considered a
change.
"""
before = self.make_project_state([self.author_name_deconstructable_1])
after = self.make_project_state([self.author_name_deconstructable_2])
... | [
"def",
"test_custom_deconstructable",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name_deconstructable_1",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name_... | [
843,
4
] | [
852,
37
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_deconstruct_field_kwarg | (self) |
Field instances are handled correctly by nested deconstruction.
|
Field instances are handled correctly by nested deconstruction.
| def test_deconstruct_field_kwarg(self):
"""
Field instances are handled correctly by nested deconstruction.
"""
before = self.make_project_state([self.author_name_deconstructable_3])
after = self.make_project_state([self.author_name_deconstructable_4])
autodetector = Migr... | [
"def",
"test_deconstruct_field_kwarg",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name_deconstructable_3",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name... | [
854,
4
] | [
862,
37
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_deconstruct_type | (self) |
#22951 -- Uninstanted classes with deconstruct are correctly returned
by deep_deconstruct during serialization.
|
#22951 -- Uninstanted classes with deconstruct are correctly returned
by deep_deconstruct during serialization.
| def test_deconstruct_type(self):
"""
#22951 -- Uninstanted classes with deconstruct are correctly returned
by deep_deconstruct during serialization.
"""
author = ModelState(
"testapp",
"Author",
[
("id", models.AutoField(primary... | [
"def",
"test_deconstruct_type",
"(",
"self",
")",
":",
"author",
"=",
"ModelState",
"(",
"\"testapp\"",
",",
"\"Author\"",
",",
"[",
"(",
"\"id\"",
",",
"models",
".",
"AutoField",
"(",
"primary_key",
"=",
"True",
")",
")",
",",
"(",
"\"name\"",
",",
"mo... | [
864,
4
] | [
887,
73
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_replace_string_with_foreignkey | (self) |
Adding an FK in the same "spot" as a deleted CharField should work. (#22300).
|
Adding an FK in the same "spot" as a deleted CharField should work. (#22300).
| def test_replace_string_with_foreignkey(self):
"""
Adding an FK in the same "spot" as a deleted CharField should work. (#22300).
"""
# Make state
before = self.make_project_state([self.author_with_publisher_string])
after = self.make_project_state([self.author_with_publis... | [
"def",
"test_replace_string_with_foreignkey",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_publisher_string",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self... | [
889,
4
] | [
903,
82
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_foreign_key_removed_before_target_model | (self) |
Removing an FK and the model it targets in the same change must remove
the FK field before the model to maintain consistency.
|
Removing an FK and the model it targets in the same change must remove
the FK field before the model to maintain consistency.
| def test_foreign_key_removed_before_target_model(self):
"""
Removing an FK and the model it targets in the same change must remove
the FK field before the model to maintain consistency.
"""
before = self.make_project_state([self.author_with_publisher, self.publisher])
aft... | [
"def",
"test_foreign_key_removed_before_target_model",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_publisher",
",",
"self",
".",
"publisher",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state"... | [
905,
4
] | [
925,
50
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_add_many_to_many | (self) |
Adding a ManyToManyField should not prompt for a default (#22435).
|
Adding a ManyToManyField should not prompt for a default (#22435).
| def test_add_many_to_many(self):
"""
Adding a ManyToManyField should not prompt for a default (#22435).
"""
class CustomQuestioner(MigrationQuestioner):
def ask_not_null_addition(self, field_name, model_name):
raise Exception("Should not have prompted for not ... | [
"def",
"test_add_many_to_many",
"(",
"self",
")",
":",
"class",
"CustomQuestioner",
"(",
"MigrationQuestioner",
")",
":",
"def",
"ask_not_null_addition",
"(",
"self",
",",
"field_name",
",",
"model_name",
")",
":",
"raise",
"Exception",
"(",
"\"Should not have promp... | [
927,
4
] | [
947,
51
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_create_with_through_model | (self) |
Adding a m2m with a through model and the models that use it should
be ordered correctly.
|
Adding a m2m with a through model and the models that use it should
be ordered correctly.
| def test_create_with_through_model(self):
"""
Adding a m2m with a through model and the models that use it should
be ordered correctly.
"""
before = self.make_project_state([])
after = self.make_project_state([self.author_with_m2m_through, self.publisher, self.contract])
... | [
"def",
"test_create_with_through_model",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_m2m_through",
",",
"self",
".",
"publishe... | [
949,
4
] | [
961,
127
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_many_to_many_removed_before_through_model | (self) |
Removing a ManyToManyField and the "through" model in the same change must remove
the field before the model to maintain consistency.
|
Removing a ManyToManyField and the "through" model in the same change must remove
the field before the model to maintain consistency.
| def test_many_to_many_removed_before_through_model(self):
"""
Removing a ManyToManyField and the "through" model in the same change must remove
the field before the model to maintain consistency.
"""
before = self.make_project_state([self.book_with_multiple_authors_through_attrib... | [
"def",
"test_many_to_many_removed_before_through_model",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"book_with_multiple_authors_through_attribution",
",",
"self",
".",
"author_name",
",",
"self",
".",
"attribution",
... | [
963,
4
] | [
991,
52
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_many_to_many_removed_before_through_model_2 | (self) |
Removing a model that contains a ManyToManyField and the
"through" model in the same change must remove
the field before the model to maintain consistency.
|
Removing a model that contains a ManyToManyField and the
"through" model in the same change must remove
the field before the model to maintain consistency.
| def test_many_to_many_removed_before_through_model_2(self):
"""
Removing a model that contains a ManyToManyField and the
"through" model in the same change must remove
the field before the model to maintain consistency.
"""
before = self.make_project_state([self.book_with... | [
"def",
"test_many_to_many_removed_before_through_model_2",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"book_with_multiple_authors_through_attribution",
",",
"self",
".",
"author_name",
",",
"self",
".",
"attribution",... | [
993,
4
] | [
1006,
134
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_m2m_w_through_multistep_remove | (self) |
A model with a m2m field that specifies a "through" model cannot be removed in the same
migration as that through model as the schema will pass through an inconsistent state.
The autodetector should produce two migrations to avoid this issue.
|
A model with a m2m field that specifies a "through" model cannot be removed in the same
migration as that through model as the schema will pass through an inconsistent state.
The autodetector should produce two migrations to avoid this issue.
| def test_m2m_w_through_multistep_remove(self):
"""
A model with a m2m field that specifies a "through" model cannot be removed in the same
migration as that through model as the schema will pass through an inconsistent state.
The autodetector should produce two migrations to avoid this i... | [
"def",
"test_m2m_w_through_multistep_remove",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_m2m_through",
",",
"self",
".",
"publisher",
",",
"self",
".",
"contract",
"]",
")",
"after",
"=",
"self"... | [
1008,
4
] | [
1027,
81
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_non_circular_foreignkey_dependency_removal | (self) |
If two models with a ForeignKey from one to the other are removed at the same time,
the autodetector should remove them in the correct order.
|
If two models with a ForeignKey from one to the other are removed at the same time,
the autodetector should remove them in the correct order.
| def test_non_circular_foreignkey_dependency_removal(self):
"""
If two models with a ForeignKey from one to the other are removed at the same time,
the autodetector should remove them in the correct order.
"""
before = self.make_project_state([self.author_with_publisher, self.publ... | [
"def",
"test_non_circular_foreignkey_dependency_removal",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_publisher",
",",
"self",
".",
"publisher_with_author",
"]",
")",
"after",
"=",
"self",
".",
"make... | [
1029,
4
] | [
1041,
118
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_alter_model_options | (self) |
Changing a model's options should make a change
|
Changing a model's options should make a change
| def test_alter_model_options(self):
"""
Changing a model's options should make a change
"""
before = self.make_project_state([self.author_empty])
after = self.make_project_state([self.author_with_options])
autodetector = MigrationAutodetector(before, after)
change... | [
"def",
"test_alter_model_options",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_with_options",
"]",
"... | [
1043,
4
] | [
1061,
79
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_alter_model_options_proxy | (self) |
Changing a proxy model's options should also make a change
|
Changing a proxy model's options should also make a change
| def test_alter_model_options_proxy(self):
"""
Changing a proxy model's options should also make a change
"""
before = self.make_project_state([self.author_proxy, self.author_empty])
after = self.make_project_state([self.author_proxy_options, self.author_empty])
autodetect... | [
"def",
"test_alter_model_options_proxy",
"(",
"self",
")",
":",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_proxy",
",",
"self",
".",
"author_empty",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"s... | [
1063,
4
] | [
1074,
79
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_set_alter_order_with_respect_to | (self) | Tests that setting order_with_respect_to adds a field | Tests that setting order_with_respect_to adds a field | def test_set_alter_order_with_respect_to(self):
"Tests that setting order_with_respect_to adds a field"
# Make state
before = self.make_project_state([self.book, self.author_with_book])
after = self.make_project_state([self.book, self.author_with_book_order_wrt])
autodetector = M... | [
"def",
"test_set_alter_order_with_respect_to",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"book",
",",
"self",
".",
"author_with_book",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state"... | [
1076,
4
] | [
1086,
109
] | python | en | ['en', 'en', 'en'] | True |
AutodetectorTests.test_add_alter_order_with_respect_to | (self) |
Tests that setting order_with_respect_to when adding the FK too
does things in the right order.
|
Tests that setting order_with_respect_to when adding the FK too
does things in the right order.
| def test_add_alter_order_with_respect_to(self):
"""
Tests that setting order_with_respect_to when adding the FK too
does things in the right order.
"""
# Make state
before = self.make_project_state([self.author_name])
after = self.make_project_state([self.book, se... | [
"def",
"test_add_alter_order_with_respect_to",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"boo... | [
1088,
4
] | [
1102,
109
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_remove_alter_order_with_respect_to | (self) |
Tests that removing order_with_respect_to when removing the FK too
does things in the right order.
|
Tests that removing order_with_respect_to when removing the FK too
does things in the right order.
| def test_remove_alter_order_with_respect_to(self):
"""
Tests that removing order_with_respect_to when removing the FK too
does things in the right order.
"""
# Make state
before = self.make_project_state([self.book, self.author_with_book_order_wrt])
after = self.m... | [
"def",
"test_remove_alter_order_with_respect_to",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"book",
",",
"self",
".",
"author_with_book_order_wrt",
"]",
")",
"after",
"=",
"self",
".",
"make_p... | [
1104,
4
] | [
1118,
98
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_add_model_order_with_respect_to | (self) |
Tests that setting order_with_respect_to when adding the whole model
does things in the right order.
|
Tests that setting order_with_respect_to when adding the whole model
does things in the right order.
| def test_add_model_order_with_respect_to(self):
"""
Tests that setting order_with_respect_to when adding the whole model
does things in the right order.
"""
# Make state
before = self.make_project_state([])
after = self.make_project_state([self.book, self.author_w... | [
"def",
"test_add_model_order_with_respect_to",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"book",
",",
"self",
".",
"aut... | [
1120,
4
] | [
1135,
104
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_swappable_first_inheritance | (self) |
Tests that swappable models get their CreateModel first.
|
Tests that swappable models get their CreateModel first.
| def test_swappable_first_inheritance(self):
"""
Tests that swappable models get their CreateModel first.
"""
# Make state
before = self.make_project_state([])
after = self.make_project_state([self.custom_user, self.aardvark])
autodetector = MigrationAutodetector(b... | [
"def",
"test_swappable_first_inheritance",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"custom_user",
",",
"self",
".",
"... | [
1137,
4
] | [
1150,
82
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_swappable_first_setting | (self) |
Tests that swappable models get their CreateModel first.
|
Tests that swappable models get their CreateModel first.
| def test_swappable_first_setting(self):
"""
Tests that swappable models get their CreateModel first.
"""
# Make state
before = self.make_project_state([])
after = self.make_project_state([self.custom_user_no_inherit, self.aardvark])
autodetector = MigrationAutodet... | [
"def",
"test_swappable_first_setting",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"custom_user_no_inherit",
",",
"self",
"... | [
1153,
4
] | [
1166,
82
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_bases_first | (self) |
Tests that bases of other models come first.
|
Tests that bases of other models come first.
| def test_bases_first(self):
"""
Tests that bases of other models come first.
"""
# Make state
before = self.make_project_state([])
after = self.make_project_state([self.aardvark_based_on_author, self.author_name])
autodetector = MigrationAutodetector(before, after... | [
"def",
"test_bases_first",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"aardvark_based_on_author",
",",
"self",
".",
"aut... | [
1168,
4
] | [
1181,
81
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_proxy_bases_first | (self) |
Tests that bases of proxies come first.
|
Tests that bases of proxies come first.
| def test_proxy_bases_first(self):
"""
Tests that bases of proxies come first.
"""
# Make state
before = self.make_project_state([])
after = self.make_project_state([self.author_empty, self.author_proxy, self.author_proxy_proxy])
autodetector = MigrationAutodetecto... | [
"def",
"test_proxy_bases_first",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_empty",
",",
"self",
".",
"author_pr... | [
1183,
4
] | [
1197,
90
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_pk_fk_included | (self) |
Tests that a relation used as the primary key is kept as part of CreateModel.
|
Tests that a relation used as the primary key is kept as part of CreateModel.
| def test_pk_fk_included(self):
"""
Tests that a relation used as the primary key is kept as part of CreateModel.
"""
# Make state
before = self.make_project_state([])
after = self.make_project_state([self.aardvark_pk_fk_author, self.author_name])
autodetector = Mi... | [
"def",
"test_pk_fk_included",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"aardvark_pk_fk_author",
",",
"self",
".",
"aut... | [
1199,
4
] | [
1212,
81
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_first_dependency | (self) |
Tests that a dependency to an app with no migrations uses __first__.
|
Tests that a dependency to an app with no migrations uses __first__.
| def test_first_dependency(self):
"""
Tests that a dependency to an app with no migrations uses __first__.
"""
# Load graph
loader = MigrationLoader(connection)
# Make state
before = self.make_project_state([])
after = self.make_project_state([self.book_mig... | [
"def",
"test_first_dependency",
"(",
"self",
")",
":",
"# Load graph",
"loader",
"=",
"MigrationLoader",
"(",
"connection",
")",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state"... | [
1214,
4
] | [
1231,
92
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_last_dependency | (self) |
Tests that a dependency to an app with existing migrations uses the
last migration of that app.
|
Tests that a dependency to an app with existing migrations uses the
last migration of that app.
| def test_last_dependency(self):
"""
Tests that a dependency to an app with existing migrations uses the
last migration of that app.
"""
# Load graph
loader = MigrationLoader(connection)
# Make state
before = self.make_project_state([])
after = self... | [
"def",
"test_last_dependency",
"(",
"self",
")",
":",
"# Load graph",
"loader",
"=",
"MigrationLoader",
"(",
"connection",
")",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",... | [
1234,
4
] | [
1252,
94
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_alter_fk_before_model_deletion | (self) |
Tests that ForeignKeys are altered _before_ the model they used to
refer to are deleted.
|
Tests that ForeignKeys are altered _before_ the model they used to
refer to are deleted.
| def test_alter_fk_before_model_deletion(self):
"""
Tests that ForeignKeys are altered _before_ the model they used to
refer to are deleted.
"""
# Make state
before = self.make_project_state([self.author_name, self.publisher_with_author])
after = self.make_project_... | [
"def",
"test_alter_fk_before_model_deletion",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name",
",",
"self",
".",
"publisher_with_author",
"]",
")",
"after",
"=",
"self",
".",
"make_pro... | [
1254,
4
] | [
1269,
79
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_fk_dependency_other_app | (self) |
Tests that ForeignKeys correctly depend on other apps' models (#23100)
|
Tests that ForeignKeys correctly depend on other apps' models (#23100)
| def test_fk_dependency_other_app(self):
"""
Tests that ForeignKeys correctly depend on other apps' models (#23100)
"""
# Make state
before = self.make_project_state([self.author_name, self.book])
after = self.make_project_state([self.author_with_book, self.book])
... | [
"def",
"test_fk_dependency_other_app",
"(",
"self",
")",
":",
"# Make state",
"before",
"=",
"self",
".",
"make_project_state",
"(",
"[",
"self",
".",
"author_name",
",",
"self",
".",
"book",
"]",
")",
"after",
"=",
"self",
".",
"make_project_state",
"(",
"[... | [
1271,
4
] | [
1284,
89
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_circular_dependency_mixed_addcreate | (self) |
Tests that the dependency resolver knows to put all CreateModel
before AddField and not become unsolvable (#23315)
|
Tests that the dependency resolver knows to put all CreateModel
before AddField and not become unsolvable (#23315)
| def test_circular_dependency_mixed_addcreate(self):
"""
Tests that the dependency resolver knows to put all CreateModel
before AddField and not become unsolvable (#23315)
"""
address = ModelState("a", "Address", [
("id", models.AutoField(primary_key=True)),
... | [
"def",
"test_circular_dependency_mixed_addcreate",
"(",
"self",
")",
":",
"address",
"=",
"ModelState",
"(",
"\"a\"",
",",
"\"Address\"",
",",
"[",
"(",
"\"id\"",
",",
"models",
".",
"AutoField",
"(",
"primary_key",
"=",
"True",
")",
")",
",",
"(",
"\"countr... | [
1286,
4
] | [
1315,
82
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_circular_dependency_swappable | (self) |
Tests that the dependency resolver knows to explicitly resolve
swappable models (#23322)
|
Tests that the dependency resolver knows to explicitly resolve
swappable models (#23322)
| def test_circular_dependency_swappable(self):
"""
Tests that the dependency resolver knows to explicitly resolve
swappable models (#23322)
"""
tenant = ModelState("a", "Tenant", [
("id", models.AutoField(primary_key=True)),
("primary_address", models.Forei... | [
"def",
"test_circular_dependency_swappable",
"(",
"self",
")",
":",
"tenant",
"=",
"ModelState",
"(",
"\"a\"",
",",
"\"Tenant\"",
",",
"[",
"(",
"\"id\"",
",",
"models",
".",
"AutoField",
"(",
"primary_key",
"=",
"True",
")",
")",
",",
"(",
"\"primary_addres... | [
1318,
4
] | [
1345,
92
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_circular_dependency_swappable2 | (self) |
Tests that the dependency resolver knows to explicitly resolve
swappable models but with the swappable not being the first migrated
model (#23322)
|
Tests that the dependency resolver knows to explicitly resolve
swappable models but with the swappable not being the first migrated
model (#23322)
| def test_circular_dependency_swappable2(self):
"""
Tests that the dependency resolver knows to explicitly resolve
swappable models but with the swappable not being the first migrated
model (#23322)
"""
address = ModelState("a", "Address", [
("id", models.AutoF... | [
"def",
"test_circular_dependency_swappable2",
"(",
"self",
")",
":",
"address",
"=",
"ModelState",
"(",
"\"a\"",
",",
"\"Address\"",
",",
"[",
"(",
"\"id\"",
",",
"models",
".",
"AutoField",
"(",
"primary_key",
"=",
"True",
")",
")",
",",
"(",
"\"tenant\"",
... | [
1348,
4
] | [
1376,
73
] | python | en | ['en', 'error', 'th'] | False |
AutodetectorTests.test_circular_dependency_swappable_self | (self) |
Tests that the dependency resolver knows to explicitly resolve
swappable models (#23322)
|
Tests that the dependency resolver knows to explicitly resolve
swappable models (#23322)
| def test_circular_dependency_swappable_self(self):
"""
Tests that the dependency resolver knows to explicitly resolve
swappable models (#23322)
"""
person = ModelState("a", "Person", [
("id", models.AutoField(primary_key=True)),
("parent1", models.ForeignK... | [
"def",
"test_circular_dependency_swappable_self",
"(",
"self",
")",
":",
"person",
"=",
"ModelState",
"(",
"\"a\"",
",",
"\"Person\"",
",",
"[",
"(",
"\"id\"",
",",
"models",
".",
"AutoField",
"(",
"primary_key",
"=",
"True",
")",
")",
",",
"(",
"\"parent1\"... | [
1379,
4
] | [
1396,
58
] | python | en | ['en', 'error', 'th'] | False |
with_metaclass | (meta, *bases) |
Create a base class with a metaclass.
|
Create a base class with a metaclass.
| def with_metaclass(meta, *bases):
"""
Create a base class with a metaclass.
"""
# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replaces itself with
# the actual metaclass.
class metaclass(meta):
def __new_... | [
"def",
"with_metaclass",
"(",
"meta",
",",
"*",
"bases",
")",
":",
"# This requires a bit of explanation: the basic idea is to make a dummy",
"# metaclass for one level of class instantiation that replaces itself with",
"# the actual metaclass.",
"class",
"metaclass",
"(",
"meta",
")... | [
19,
0
] | [
30,
61
] | python | en | ['en', 'error', 'th'] | False |
enlarge | (n) |
This function enlarges a given number by 100.
Params : n (integer or float) like 9 or 9.9
|
This function enlarges a given number by 100. | def enlarge(n):
"""
This function enlarges a given number by 100.
Params : n (integer or float) like 9 or 9.9
"""
return n * 100 | [
"def",
"enlarge",
"(",
"n",
")",
":",
"return",
"n",
"*",
"100"
] | [
29,
0
] | [
35,
18
] | python | en | ['en', 'error', 'th'] | False |
M2mThroughTests.test_through_fields | (self) |
Tests that relations with intermediary tables with multiple FKs
to the M2M's ``to`` model are possible.
|
Tests that relations with intermediary tables with multiple FKs
to the M2M's ``to`` model are possible.
| def test_through_fields(self):
"""
Tests that relations with intermediary tables with multiple FKs
to the M2M's ``to`` model are possible.
"""
event = Event.objects.create(title='Rockwhale 2014')
Invitation.objects.create(event=event, inviter=self.bob, invitee=self.jim)
... | [
"def",
"test_through_fields",
"(",
"self",
")",
":",
"event",
"=",
"Event",
".",
"objects",
".",
"create",
"(",
"title",
"=",
"'Rockwhale 2014'",
")",
"Invitation",
".",
"objects",
".",
"create",
"(",
"event",
"=",
"event",
",",
"inviter",
"=",
"self",
"... | [
322,
4
] | [
334,
9
] | python | en | ['en', 'error', 'th'] | False |
BoundaryAttackPlusPlus | (model, sess, dtypestr="float32", **kwargs) |
A previous name used for HopSkipJumpAttack.
|
A previous name used for HopSkipJumpAttack.
| def BoundaryAttackPlusPlus(model, sess, dtypestr="float32", **kwargs):
"""
A previous name used for HopSkipJumpAttack.
"""
warn(
"BoundaryAttackPlusPlus will be removed after 2019-12-08; use HopSkipJumpAttack."
)
return HopSkipJumpAttack(model, sess, dtypestr, **kwargs) | [
"def",
"BoundaryAttackPlusPlus",
"(",
"model",
",",
"sess",
",",
"dtypestr",
"=",
"\"float32\"",
",",
"*",
"*",
"kwargs",
")",
":",
"warn",
"(",
"\"BoundaryAttackPlusPlus will be removed after 2019-12-08; use HopSkipJumpAttack.\"",
")",
"return",
"HopSkipJumpAttack",
"(",... | [
373,
0
] | [
380,
61
] | python | en | ['en', 'error', 'th'] | False |
clip_image | (image, clip_min, clip_max) | Clip an image, or an image batch, with upper and lower threshold. | Clip an image, or an image batch, with upper and lower threshold. | def clip_image(image, clip_min, clip_max):
""" Clip an image, or an image batch, with upper and lower threshold. """
return np.minimum(np.maximum(clip_min, image), clip_max) | [
"def",
"clip_image",
"(",
"image",
",",
"clip_min",
",",
"clip_max",
")",
":",
"return",
"np",
".",
"minimum",
"(",
"np",
".",
"maximum",
"(",
"clip_min",
",",
"image",
")",
",",
"clip_max",
")"
] | [
393,
0
] | [
395,
60
] | python | en | ['en', 'en', 'en'] | True |
compute_distance | (x_ori, x_pert, constraint="l2") | Compute the distance between two images. | Compute the distance between two images. | def compute_distance(x_ori, x_pert, constraint="l2"):
""" Compute the distance between two images. """
if constraint == "l2":
dist = np.linalg.norm(x_ori - x_pert)
elif constraint == "linf":
dist = np.max(abs(x_ori - x_pert))
return dist | [
"def",
"compute_distance",
"(",
"x_ori",
",",
"x_pert",
",",
"constraint",
"=",
"\"l2\"",
")",
":",
"if",
"constraint",
"==",
"\"l2\"",
":",
"dist",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"x_ori",
"-",
"x_pert",
")",
"elif",
"constraint",
"==",
"\... | [
398,
0
] | [
404,
15
] | python | en | ['en', 'en', 'en'] | True |
approximate_gradient | (
decision_function, sample, num_evals, delta, constraint, shape, clip_min, clip_max
) | Gradient direction estimation | Gradient direction estimation | def approximate_gradient(
decision_function, sample, num_evals, delta, constraint, shape, clip_min, clip_max
):
""" Gradient direction estimation """
# Generate random vectors.
noise_shape = [num_evals] + list(shape)
if constraint == "l2":
rv = np.random.randn(*noise_shape)
elif constrai... | [
"def",
"approximate_gradient",
"(",
"decision_function",
",",
"sample",
",",
"num_evals",
",",
"delta",
",",
"constraint",
",",
"shape",
",",
"clip_min",
",",
"clip_max",
")",
":",
"# Generate random vectors.",
"noise_shape",
"=",
"[",
"num_evals",
"]",
"+",
"li... | [
407,
0
] | [
441,
16
] | python | fr | ['fr', 'fr', 'en'] | True |
project | (original_image, perturbed_images, alphas, shape, constraint) | Projection onto given l2 / linf balls in a batch. | Projection onto given l2 / linf balls in a batch. | def project(original_image, perturbed_images, alphas, shape, constraint):
""" Projection onto given l2 / linf balls in a batch. """
alphas_shape = [len(alphas)] + [1] * len(shape)
alphas = alphas.reshape(alphas_shape)
if constraint == "l2":
projected = (1 - alphas) * original_image + alphas * pe... | [
"def",
"project",
"(",
"original_image",
",",
"perturbed_images",
",",
"alphas",
",",
"shape",
",",
"constraint",
")",
":",
"alphas_shape",
"=",
"[",
"len",
"(",
"alphas",
")",
"]",
"+",
"[",
"1",
"]",
"*",
"len",
"(",
"shape",
")",
"alphas",
"=",
"a... | [
444,
0
] | [
454,
20
] | python | en | ['en', 'en', 'en'] | True |
binary_search_batch | (
original_image, perturbed_images, decision_function, shape, constraint, theta
) | Binary search to approach the boundary. | Binary search to approach the boundary. | def binary_search_batch(
original_image, perturbed_images, decision_function, shape, constraint, theta
):
""" Binary search to approach the boundary. """
# Compute distance between each of perturbed image and original image.
dists_post_update = np.array(
[
compute_distance(original_... | [
"def",
"binary_search_batch",
"(",
"original_image",
",",
"perturbed_images",
",",
"decision_function",
",",
"shape",
",",
"constraint",
",",
"theta",
")",
":",
"# Compute distance between each of perturbed image and original image.",
"dists_post_update",
"=",
"np",
".",
"a... | [
457,
0
] | [
505,
26
] | python | en | ['en', 'en', 'en'] | True |
initialize | (decision_function, sample, shape, clip_min, clip_max) |
Efficient Implementation of BlendedUniformNoiseAttack in Foolbox.
|
Efficient Implementation of BlendedUniformNoiseAttack in Foolbox.
| def initialize(decision_function, sample, shape, clip_min, clip_max):
"""
Efficient Implementation of BlendedUniformNoiseAttack in Foolbox.
"""
success = 0
num_evals = 0
# Find a misclassified random noise.
while True:
random_noise = np.random.uniform(clip_min, clip_max, size=shape)... | [
"def",
"initialize",
"(",
"decision_function",
",",
"sample",
",",
"shape",
",",
"clip_min",
",",
"clip_max",
")",
":",
"success",
"=",
"0",
"num_evals",
"=",
"0",
"# Find a misclassified random noise.",
"while",
"True",
":",
"random_noise",
"=",
"np",
".",
"r... | [
508,
0
] | [
540,
25
] | python | en | ['en', 'error', 'th'] | False |
geometric_progression_for_stepsize | (
x, update, dist, decision_function, current_iteration
) | Geometric progression to search for stepsize.
Keep decreasing stepsize by half until reaching
the desired side of the boundary.
| Geometric progression to search for stepsize.
Keep decreasing stepsize by half until reaching
the desired side of the boundary.
| def geometric_progression_for_stepsize(
x, update, dist, decision_function, current_iteration
):
"""Geometric progression to search for stepsize.
Keep decreasing stepsize by half until reaching
the desired side of the boundary.
"""
epsilon = dist / np.sqrt(current_iteration)
while True:
... | [
"def",
"geometric_progression_for_stepsize",
"(",
"x",
",",
"update",
",",
"dist",
",",
"decision_function",
",",
"current_iteration",
")",
":",
"epsilon",
"=",
"dist",
"/",
"np",
".",
"sqrt",
"(",
"current_iteration",
")",
"while",
"True",
":",
"updated",
"="... | [
543,
0
] | [
559,
18
] | python | en | ['en', 'en', 'en'] | True |
select_delta | (
dist_post_update, current_iteration, clip_max, clip_min, d, theta, constraint
) |
Choose the delta at the scale of distance
between x and perturbed sample.
|
Choose the delta at the scale of distance
between x and perturbed sample.
| def select_delta(
dist_post_update, current_iteration, clip_max, clip_min, d, theta, constraint
):
"""
Choose the delta at the scale of distance
between x and perturbed sample.
"""
if current_iteration == 1:
delta = 0.1 * (clip_max - clip_min)
else:
if constraint == "l2":
... | [
"def",
"select_delta",
"(",
"dist_post_update",
",",
"current_iteration",
",",
"clip_max",
",",
"clip_min",
",",
"d",
",",
"theta",
",",
"constraint",
")",
":",
"if",
"current_iteration",
"==",
"1",
":",
"delta",
"=",
"0.1",
"*",
"(",
"clip_max",
"-",
"cli... | [
562,
0
] | [
577,
16
] | python | en | ['en', 'error', 'th'] | False |
HopSkipJumpAttack.__init__ | (self, model, sess, dtypestr="float32", **kwargs) |
Note: the model parameter should be an instance of the
cleverhans.model.Model abstraction provided by CleverHans.
|
Note: the model parameter should be an instance of the
cleverhans.model.Model abstraction provided by CleverHans.
| def __init__(self, model, sess, dtypestr="float32", **kwargs):
"""
Note: the model parameter should be an instance of the
cleverhans.model.Model abstraction provided by CleverHans.
"""
if not isinstance(model, Model):
wrapper_warning_logits()
model = Calla... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"sess",
",",
"dtypestr",
"=",
"\"float32\"",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"model",
",",
"Model",
")",
":",
"wrapper_warning_logits",
"(",
")",
"model",
"=",
"Calla... | [
34,
4
] | [
58,
9
] | python | en | ['en', 'error', 'th'] | False |
HopSkipJumpAttack.generate | (self, x, **kwargs) |
Return a tensor that constructs adversarial examples for the given
input. Generate uses tf.py_func in order to operate over tensors.
:param x: A tensor with the inputs.
:param kwargs: See `parse_params`
|
Return a tensor that constructs adversarial examples for the given
input. Generate uses tf.py_func in order to operate over tensors.
:param x: A tensor with the inputs.
:param kwargs: See `parse_params`
| def generate(self, x, **kwargs):
"""
Return a tensor that constructs adversarial examples for the given
input. Generate uses tf.py_func in order to operate over tensors.
:param x: A tensor with the inputs.
:param kwargs: See `parse_params`
"""
self.parse_params(**... | [
"def",
"generate",
"(",
"self",
",",
"x",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"parse_params",
"(",
"*",
"*",
"kwargs",
")",
"shape",
"=",
"[",
"int",
"(",
"i",
")",
"for",
"i",
"in",
"x",
".",
"get_shape",
"(",
")",
".",
"as_list",
... | [
60,
4
] | [
124,
19
] | python | en | ['en', 'error', 'th'] | False |
HopSkipJumpAttack.generate_np | (self, x, **kwargs) |
Generate adversarial images in a for loop.
:param y: An array of shape (n, nb_classes) for true labels.
:param y_target: An array of shape (n, nb_classes) for target labels.
Required for targeted attack.
:param image_target: An array of shape (n, **image shape) for initial
... |
Generate adversarial images in a for loop.
:param y: An array of shape (n, nb_classes) for true labels.
:param y_target: An array of shape (n, nb_classes) for target labels.
Required for targeted attack.
:param image_target: An array of shape (n, **image shape) for initial
... | def generate_np(self, x, **kwargs):
"""
Generate adversarial images in a for loop.
:param y: An array of shape (n, nb_classes) for true labels.
:param y_target: An array of shape (n, nb_classes) for target labels.
Required for targeted attack.
:param image_target: An arr... | [
"def",
"generate_np",
"(",
"self",
",",
"x",
",",
"*",
"*",
"kwargs",
")",
":",
"x_adv",
"=",
"[",
"]",
"if",
"\"image_target\"",
"in",
"kwargs",
"and",
"kwargs",
"[",
"\"image_target\"",
"]",
"is",
"not",
"None",
":",
"image_target",
"=",
"np",
".",
... | [
126,
4
] | [
162,
44
] | python | en | ['en', 'error', 'th'] | False |
HopSkipJumpAttack.parse_params | (
self,
y_target=None,
image_target=None,
initial_num_evals=100,
max_num_evals=10000,
stepsize_search="geometric_progression",
num_iterations=64,
gamma=1.0,
constraint="l2",
batch_size=128,
verbose=True,
clip_min=0,
... |
:param y: A tensor of shape (1, nb_classes) for true labels.
:param y_target: A tensor of shape (1, nb_classes) for target labels.
Required for targeted attack.
:param image_target: A tensor of shape (1, **image shape) for initial
target images. Required for targeted attack.
... |
:param y: A tensor of shape (1, nb_classes) for true labels.
:param y_target: A tensor of shape (1, nb_classes) for target labels.
Required for targeted attack.
:param image_target: A tensor of shape (1, **image shape) for initial
target images. Required for targeted attack.
... | def parse_params(
self,
y_target=None,
image_target=None,
initial_num_evals=100,
max_num_evals=10000,
stepsize_search="geometric_progression",
num_iterations=64,
gamma=1.0,
constraint="l2",
batch_size=128,
verbose=True,
clip... | [
"def",
"parse_params",
"(",
"self",
",",
"y_target",
"=",
"None",
",",
"image_target",
"=",
"None",
",",
"initial_num_evals",
"=",
"100",
",",
"max_num_evals",
"=",
"10000",
",",
"stepsize_search",
"=",
"\"geometric_progression\"",
",",
"num_iterations",
"=",
"6... | [
164,
4
] | [
218,
30
] | python | en | ['en', 'error', 'th'] | False |
HopSkipJumpAttack._hsja | (self, sample, target_label, target_image) |
Main algorithm for HopSkipJumpAttack.
Return a tensor that constructs adversarial examples for the given
input. Generate uses tf.py_func in order to operate over tensors.
:param sample: input image. Without the batchsize dimension.
:param target_label: integer for targeted att... |
Main algorithm for HopSkipJumpAttack. | def _hsja(self, sample, target_label, target_image):
"""
Main algorithm for HopSkipJumpAttack.
Return a tensor that constructs adversarial examples for the given
input. Generate uses tf.py_func in order to operate over tensors.
:param sample: input image. Without the batchsize ... | [
"def",
"_hsja",
"(",
"self",
",",
"sample",
",",
"target_label",
",",
"target_image",
")",
":",
"# Original label required for untargeted attack.",
"if",
"target_label",
"is",
"None",
":",
"original_label",
"=",
"np",
".",
"argmax",
"(",
"self",
".",
"sess",
"."... | [
220,
4
] | [
370,
24
] | python | en | ['en', 'error', 'th'] | False |
validate_system | (system) |
Ensure build system has the requisite fields.
|
Ensure build system has the requisite fields.
| def validate_system(system):
"""
Ensure build system has the requisite fields.
"""
required = {'requires', 'build-backend'}
if not (required <= set(system)):
message = "Missing required fields: {missing}".format(
missing=required-set(system),
)
raise ValueError(me... | [
"def",
"validate_system",
"(",
"system",
")",
":",
"required",
"=",
"{",
"'requires'",
",",
"'build-backend'",
"}",
"if",
"not",
"(",
"required",
"<=",
"set",
"(",
"system",
")",
")",
":",
"message",
"=",
"\"Missing required fields: {missing}\"",
".",
"format"... | [
16,
0
] | [
25,
33
] | python | en | ['en', 'error', 'th'] | False |
load_system | (source_dir) |
Load the build system from a source dir (pyproject.toml).
|
Load the build system from a source dir (pyproject.toml).
| def load_system(source_dir):
"""
Load the build system from a source dir (pyproject.toml).
"""
pyproject = os.path.join(source_dir, 'pyproject.toml')
with open(pyproject) as f:
pyproject_data = toml.load(f)
return pyproject_data['build-system'] | [
"def",
"load_system",
"(",
"source_dir",
")",
":",
"pyproject",
"=",
"os",
".",
"path",
".",
"join",
"(",
"source_dir",
",",
"'pyproject.toml'",
")",
"with",
"open",
"(",
"pyproject",
")",
"as",
"f",
":",
"pyproject_data",
"=",
"toml",
".",
"load",
"(",
... | [
28,
0
] | [
35,
41
] | python | en | ['en', 'error', 'th'] | False |
compat_system | (source_dir) |
Given a source dir, attempt to get a build system backend
and requirements from pyproject.toml. Fallback to
setuptools but only if the file was not found or a build
system was not indicated.
|
Given a source dir, attempt to get a build system backend
and requirements from pyproject.toml. Fallback to
setuptools but only if the file was not found or a build
system was not indicated.
| def compat_system(source_dir):
"""
Given a source dir, attempt to get a build system backend
and requirements from pyproject.toml. Fallback to
setuptools but only if the file was not found or a build
system was not indicated.
"""
try:
system = load_system(source_dir)
except (File... | [
"def",
"compat_system",
"(",
"source_dir",
")",
":",
"try",
":",
"system",
"=",
"load_system",
"(",
"source_dir",
")",
"except",
"(",
"FileNotFoundError",
",",
"KeyError",
")",
":",
"system",
"=",
"{",
"}",
"system",
".",
"setdefault",
"(",
"'build-backend'"... | [
38,
0
] | [
54,
17
] | python | en | ['en', 'error', 'th'] | False |
_normalize_name | (name) | Make a name consistent regardless of source (environment or file)
| Make a name consistent regardless of source (environment or file)
| def _normalize_name(name):
# type: (str) -> str
"""Make a name consistent regardless of source (environment or file)
"""
name = name.lower().replace('_', '-')
if name.startswith('--'):
name = name[2:] # only prefer long opts
return name | [
"def",
"_normalize_name",
"(",
"name",
")",
":",
"# type: (str) -> str",
"name",
"=",
"name",
".",
"lower",
"(",
")",
".",
"replace",
"(",
"'_'",
",",
"'-'",
")",
"if",
"name",
".",
"startswith",
"(",
"'--'",
")",
":",
"name",
"=",
"name",
"[",
"2",
... | [
44,
0
] | [
51,
15
] | python | en | ['en', 'en', 'en'] | True |
Configuration.load | (self) | Loads configuration from configuration files and environment
| Loads configuration from configuration files and environment
| def load(self):
# type: () -> None
"""Loads configuration from configuration files and environment
"""
self._load_config_files()
if not self.isolated:
self._load_environment_vars() | [
"def",
"load",
"(",
"self",
")",
":",
"# type: () -> None",
"self",
".",
"_load_config_files",
"(",
")",
"if",
"not",
"self",
".",
"isolated",
":",
"self",
".",
"_load_environment_vars",
"(",
")"
] | [
145,
4
] | [
151,
41
] | python | en | ['en', 'en', 'en'] | True |
Configuration.get_file_to_edit | (self) | Returns the file with highest priority in configuration
| Returns the file with highest priority in configuration
| def get_file_to_edit(self):
# type: () -> Optional[str]
"""Returns the file with highest priority in configuration
"""
assert self.load_only is not None, \
"Need to be specified a file to be editing"
try:
return self._get_parser_to_modify()[0]
exc... | [
"def",
"get_file_to_edit",
"(",
"self",
")",
":",
"# type: () -> Optional[str]",
"assert",
"self",
".",
"load_only",
"is",
"not",
"None",
",",
"\"Need to be specified a file to be editing\"",
"try",
":",
"return",
"self",
".",
"_get_parser_to_modify",
"(",
")",
"[",
... | [
153,
4
] | [
163,
23
] | python | en | ['en', 'en', 'en'] | True |
Configuration.items | (self) | Returns key-value pairs like dict.items() representing the loaded
configuration
| Returns key-value pairs like dict.items() representing the loaded
configuration
| def items(self):
# type: () -> Iterable[Tuple[str, Any]]
"""Returns key-value pairs like dict.items() representing the loaded
configuration
"""
return self._dictionary.items() | [
"def",
"items",
"(",
"self",
")",
":",
"# type: () -> Iterable[Tuple[str, Any]]",
"return",
"self",
".",
"_dictionary",
".",
"items",
"(",
")"
] | [
165,
4
] | [
170,
39
] | python | en | ['en', 'en', 'en'] | True |
Configuration.get_value | (self, key) | Get a value from the configuration.
| Get a value from the configuration.
| def get_value(self, key):
# type: (str) -> Any
"""Get a value from the configuration.
"""
try:
return self._dictionary[key]
except KeyError:
raise ConfigurationError("No such key - {}".format(key)) | [
"def",
"get_value",
"(",
"self",
",",
"key",
")",
":",
"# type: (str) -> Any",
"try",
":",
"return",
"self",
".",
"_dictionary",
"[",
"key",
"]",
"except",
"KeyError",
":",
"raise",
"ConfigurationError",
"(",
"\"No such key - {}\"",
".",
"format",
"(",
"key",
... | [
172,
4
] | [
179,
68
] | python | en | ['en', 'en', 'en'] | True |
Configuration.set_value | (self, key, value) | Modify a value in the configuration.
| Modify a value in the configuration.
| def set_value(self, key, value):
# type: (str, Any) -> None
"""Modify a value in the configuration.
"""
self._ensure_have_load_only()
fname, parser = self._get_parser_to_modify()
if parser is not None:
section, name = _disassemble_key(key)
# Mod... | [
"def",
"set_value",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"# type: (str, Any) -> None",
"self",
".",
"_ensure_have_load_only",
"(",
")",
"fname",
",",
"parser",
"=",
"self",
".",
"_get_parser_to_modify",
"(",
")",
"if",
"parser",
"is",
"not",
"Non... | [
181,
4
] | [
198,
45
] | python | en | ['en', 'it', 'en'] | True |
Configuration.unset_value | (self, key) | Unset a value in the configuration.
| Unset a value in the configuration.
| def unset_value(self, key):
# type: (str) -> None
"""Unset a value in the configuration.
"""
self._ensure_have_load_only()
if key not in self._config[self.load_only]:
raise ConfigurationError("No such key - {}".format(key))
fname, parser = self._get_parser_t... | [
"def",
"unset_value",
"(",
"self",
",",
"key",
")",
":",
"# type: (str) -> None",
"self",
".",
"_ensure_have_load_only",
"(",
")",
"if",
"key",
"not",
"in",
"self",
".",
"_config",
"[",
"self",
".",
"load_only",
"]",
":",
"raise",
"ConfigurationError",
"(",
... | [
200,
4
] | [
237,
45
] | python | en | ['en', 'en', 'en'] | True |
Configuration.save | (self) | Save the current in-memory state.
| Save the current in-memory state.
| def save(self):
# type: () -> None
"""Save the current in-memory state.
"""
self._ensure_have_load_only()
for fname, parser in self._modified_parsers:
logger.info("Writing to %s", fname)
# Ensure directory exists.
ensure_dir(os.path.dirname(f... | [
"def",
"save",
"(",
"self",
")",
":",
"# type: () -> None",
"self",
".",
"_ensure_have_load_only",
"(",
")",
"for",
"fname",
",",
"parser",
"in",
"self",
".",
"_modified_parsers",
":",
"logger",
".",
"info",
"(",
"\"Writing to %s\"",
",",
"fname",
")",
"# En... | [
239,
4
] | [
252,
31
] | python | en | ['en', 'en', 'en'] | True |
Configuration._dictionary | (self) | A dictionary representing the loaded configuration.
| A dictionary representing the loaded configuration.
| def _dictionary(self):
# type: () -> Dict[str, Any]
"""A dictionary representing the loaded configuration.
"""
# NOTE: Dictionaries are not populated if not loaded. So, conditionals
# are not needed here.
retval = {}
for variant in self._override_order:
... | [
"def",
"_dictionary",
"(",
"self",
")",
":",
"# type: () -> Dict[str, Any]",
"# NOTE: Dictionaries are not populated if not loaded. So, conditionals",
"# are not needed here.",
"retval",
"=",
"{",
"}",
"for",
"variant",
"in",
"self",
".",
"_override_order",
":",
"retval... | [
265,
4
] | [
276,
21
] | python | en | ['en', 'en', 'en'] | True |
Configuration._load_config_files | (self) | Loads configuration from configuration files
| Loads configuration from configuration files
| def _load_config_files(self):
# type: () -> None
"""Loads configuration from configuration files
"""
config_files = dict(self._iter_config_files())
if config_files[kinds.ENV][0:1] == [os.devnull]:
logger.debug(
"Skipping loading configuration files due... | [
"def",
"_load_config_files",
"(",
"self",
")",
":",
"# type: () -> None",
"config_files",
"=",
"dict",
"(",
"self",
".",
"_iter_config_files",
"(",
")",
")",
"if",
"config_files",
"[",
"kinds",
".",
"ENV",
"]",
"[",
"0",
":",
"1",
"]",
"==",
"[",
"os",
... | [
278,
4
] | [
303,
62
] | python | en | ['en', 'en', 'en'] | True |
Configuration._load_environment_vars | (self) | Loads configuration from environment variables
| Loads configuration from environment variables
| def _load_environment_vars(self):
# type: () -> None
"""Loads configuration from environment variables
"""
self._config[kinds.ENV_VAR].update(
self._normalized_keys(":env:", self._get_environ_vars())
) | [
"def",
"_load_environment_vars",
"(",
"self",
")",
":",
"# type: () -> None",
"self",
".",
"_config",
"[",
"kinds",
".",
"ENV_VAR",
"]",
".",
"update",
"(",
"self",
".",
"_normalized_keys",
"(",
"\":env:\"",
",",
"self",
".",
"_get_environ_vars",
"(",
")",
"... | [
339,
4
] | [
345,
9
] | python | en | ['en', 'en', 'en'] | True |
Configuration._normalized_keys | (self, section, items) | Normalizes items to construct a dictionary with normalized keys.
This routine is where the names become keys and are made the same
regardless of source - configuration files or environment.
| Normalizes items to construct a dictionary with normalized keys. | def _normalized_keys(self, section, items):
# type: (str, Iterable[Tuple[str, Any]]) -> Dict[str, Any]
"""Normalizes items to construct a dictionary with normalized keys.
This routine is where the names become keys and are made the same
regardless of source - configuration files or envi... | [
"def",
"_normalized_keys",
"(",
"self",
",",
"section",
",",
"items",
")",
":",
"# type: (str, Iterable[Tuple[str, Any]]) -> Dict[str, Any]",
"normalized",
"=",
"{",
"}",
"for",
"name",
",",
"val",
"in",
"items",
":",
"key",
"=",
"section",
"+",
"\".\"",
"+",
... | [
347,
4
] | [
358,
25
] | python | en | ['en', 'en', 'en'] | True |
Configuration._get_environ_vars | (self) | Returns a generator with all environmental vars with prefix PIP_ | Returns a generator with all environmental vars with prefix PIP_ | def _get_environ_vars(self):
# type: () -> Iterable[Tuple[str, str]]
"""Returns a generator with all environmental vars with prefix PIP_"""
for key, val in os.environ.items():
should_be_yielded = (
key.startswith("PIP_") and
key[4:].lower() not in self... | [
"def",
"_get_environ_vars",
"(",
"self",
")",
":",
"# type: () -> Iterable[Tuple[str, str]]",
"for",
"key",
",",
"val",
"in",
"os",
".",
"environ",
".",
"items",
"(",
")",
":",
"should_be_yielded",
"=",
"(",
"key",
".",
"startswith",
"(",
"\"PIP_\"",
")",
"a... | [
360,
4
] | [
369,
42
] | python | en | ['en', 'en', 'en'] | True |
Configuration._iter_config_files | (self) | Yields variant and configuration files associated with it.
This should be treated like items of a dictionary.
| Yields variant and configuration files associated with it. | def _iter_config_files(self):
# type: () -> Iterable[Tuple[Kind, List[str]]]
"""Yields variant and configuration files associated with it.
This should be treated like items of a dictionary.
"""
# SMELL: Move the conditions out of this function
# environment variables ha... | [
"def",
"_iter_config_files",
"(",
"self",
")",
":",
"# type: () -> Iterable[Tuple[Kind, List[str]]]",
"# SMELL: Move the conditions out of this function",
"# environment variables have the lowest priority",
"config_file",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PIP_CONFIG_FIL... | [
372,
4
] | [
401,
50
] | python | en | ['en', 'en', 'en'] | True |
main | (args=None) | This is preserved for old console scripts that may still be referencing
it.
For additional details, see https://github.com/pypa/pip/issues/7498.
| This is preserved for old console scripts that may still be referencing
it. | def main(args=None):
# type: (Optional[List[str]]) -> int
"""This is preserved for old console scripts that may still be referencing
it.
For additional details, see https://github.com/pypa/pip/issues/7498.
"""
from pip._internal.utils.entrypoints import _wrapper
return _wrapper(args) | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"# type: (Optional[List[str]]) -> int",
"from",
"pip",
".",
"_internal",
".",
"utils",
".",
"entrypoints",
"import",
"_wrapper",
"return",
"_wrapper",
"(",
"args",
")"
] | [
7,
0
] | [
16,
25
] | python | en | ['en', 'en', 'en'] | True |
GeometryField.to_python | (self, value) | Transform the value to a Geometry object. | Transform the value to a Geometry object. | def to_python(self, value):
"""Transform the value to a Geometry object."""
if value in self.empty_values:
return None
if not isinstance(value, GEOSGeometry):
if hasattr(self.widget, 'deserialize'):
try:
value = self.widget.deserialize... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"in",
"self",
".",
"empty_values",
":",
"return",
"None",
"if",
"not",
"isinstance",
"(",
"value",
",",
"GEOSGeometry",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"widget",
",",
... | [
32,
4
] | [
58,
20
] | python | en | ['en', 'en', 'en'] | True |
GeometryField.clean | (self, value) |
Validate that the input value can be converted to a Geometry object
and return it. Raise a ValidationError if the value cannot be
instantiated as a Geometry.
|
Validate that the input value can be converted to a Geometry object
and return it. Raise a ValidationError if the value cannot be
instantiated as a Geometry.
| def clean(self, value):
"""
Validate that the input value can be converted to a Geometry object
and return it. Raise a ValidationError if the value cannot be
instantiated as a Geometry.
"""
geom = super().clean(value)
if geom is None:
return geom
... | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"geom",
"=",
"super",
"(",
")",
".",
"clean",
"(",
"value",
")",
"if",
"geom",
"is",
"None",
":",
"return",
"geom",
"# Ensuring that the geometry is of the correct type (indicated",
"# using the OGC string label... | [
60,
4
] | [
83,
19
] | python | en | ['en', 'error', 'th'] | False |
GeometryField.has_changed | (self, initial, data) | Compare geographic value of data with its initial value. | Compare geographic value of data with its initial value. | def has_changed(self, initial, data):
""" Compare geographic value of data with its initial value. """
try:
data = self.to_python(data)
initial = self.to_python(initial)
except forms.ValidationError:
return True
# Only do a geographic comparison if b... | [
"def",
"has_changed",
"(",
"self",
",",
"initial",
",",
"data",
")",
":",
"try",
":",
"data",
"=",
"self",
".",
"to_python",
"(",
"data",
")",
"initial",
"=",
"self",
".",
"to_python",
"(",
"initial",
")",
"except",
"forms",
".",
"ValidationError",
":"... | [
85,
4
] | [
103,
46
] | python | en | ['en', 'en', 'en'] | True |
_logout_locally_and_in_tunnistamo | (request, redirect_uri=None) |
Log out locally and in Tunnistamo.
:type request: django.http.HttpRequest
|
Log out locally and in Tunnistamo. | def _logout_locally_and_in_tunnistamo(request, redirect_uri=None):
"""
Log out locally and in Tunnistamo.
:type request: django.http.HttpRequest
"""
# First logout locally
django_auth.logout(request)
# Then logout from Tunnistamo with a redirect which points
# back to this view with a ... | [
"def",
"_logout_locally_and_in_tunnistamo",
"(",
"request",
",",
"redirect_uri",
"=",
"None",
")",
":",
"# First logout locally",
"django_auth",
".",
"logout",
"(",
"request",
")",
"# Then logout from Tunnistamo with a redirect which points",
"# back to this view with a given nex... | [
83,
0
] | [
98,
74
] | python | en | ['en', 'error', 'th'] | False |
gravatar_hash | (email: str) | Compute the Gravatar hash for an email address. | Compute the Gravatar hash for an email address. | def gravatar_hash(email: str) -> str:
"""Compute the Gravatar hash for an email address."""
# Non-ASCII characters aren't permitted by the currently active e-mail
# RFCs. However, the IETF has published https://tools.ietf.org/html/rfc4952,
# outlining internationalization of email addresses, and regardl... | [
"def",
"gravatar_hash",
"(",
"email",
":",
"str",
")",
"->",
"str",
":",
"# Non-ASCII characters aren't permitted by the currently active e-mail",
"# RFCs. However, the IETF has published https://tools.ietf.org/html/rfc4952,",
"# outlining internationalization of email addresses, and regardl... | [
8,
0
] | [
15,
55
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.