Commit 5ef81504 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

refactor(renaming): revert renaming of maxsize to max_size

parent 9feeb998095b
Pipeline #8334 passed with stages
in 6 minutes and 24 seconds
......@@ -79,6 +79,6 @@ class EPermission(EntityType):
indexed=True,
internationalizable=True,
fulltextindexed=True,
max_size=100,
maxsize=100,
description=_("name or identifier of the permission"),
)
......@@ -29,8 +29,8 @@ from yams.buildobjs import (
class Affaire(EntityType):
sujet = String(max_size=128)
ref = String(max_size=12)
sujet = String(maxsize=128)
ref = String(maxsize=12)
concerne = SubjectRelation("Societe")
obj_wildcard = SubjectRelation("*")
......@@ -45,14 +45,14 @@ class subj_wildcard(RelationDefinition):
class Person(EntityType):
__unique_together__ = [("nom", "prenom")]
nom = String(max_size=64, fulltextindexed=True, required=True)
prenom = String(max_size=64, fulltextindexed=True)
sexe = String(max_size=1, default="M")
nom = String(maxsize=64, fulltextindexed=True, required=True)
prenom = String(maxsize=64, fulltextindexed=True)
sexe = String(maxsize=1, default="M")
promo = String(vocabulary=("bon", "pasbon"))
titre = String(max_size=128, fulltextindexed=True)
adel = String(max_size=128)
ass = String(max_size=128)
web = String(max_size=128)
titre = String(maxsize=128, fulltextindexed=True)
adel = String(maxsize=128)
ass = String(maxsize=128)
web = String(maxsize=128)
tel = Int(__permissions__={"read": (), "add": ("managers",), "update": ("managers",)})
fax = Int()
datenaiss = Date()
......@@ -70,36 +70,36 @@ class Salaried(Person):
class Societe(EntityType):
nom = String(max_size=64, fulltextindexed=True)
web = String(max_size=128)
nom = String(maxsize=64, fulltextindexed=True)
web = String(maxsize=128)
tel = Int()
fax = Int()
rncs = String(max_size=32)
ad1 = String(max_size=128)
ad2 = String(max_size=128)
ad3 = String(max_size=128)
cp = String(max_size=12)
ville = String(max_size=32)
rncs = String(maxsize=32)
ad1 = String(maxsize=128)
ad2 = String(maxsize=128)
ad3 = String(maxsize=128)
cp = String(maxsize=12)
ville = String(maxsize=32)
evaluee = SubjectRelation("Note")
class Note(EntityType):
date = String(max_size=10)
type = String(max_size=1)
para = String(max_size=512)
date = String(maxsize=10)
type = String(maxsize=1)
para = String(maxsize=512)
class pkginfo(EntityType):
modname = String(max_size=30, required=True)
version = String(max_size=10, required=True, default="0.1")
modname = String(maxsize=30, required=True)
version = String(maxsize=10, required=True, default="0.1")
copyright = String(required=True)
license = String(vocabulary=("GPL", "ZPL"))
short_desc = String(max_size=80, required=True)
short_desc = String(maxsize=80, required=True)
long_desc = String(required=True, fulltextindexed=True)
author = String(max_size=100, required=True)
author_email = String(max_size=100, required=True)
mailinglist = String(max_size=100)
author = String(maxsize=100, required=True)
author_email = String(maxsize=100, required=True)
mailinglist = String(maxsize=100)
debian_handler = String(vocabulary=("machin", "bidule"))
......
......@@ -69,7 +69,7 @@ def create_schema_1():
def create_schema_2():
class Affaire(EntityType):
nom = String(max_size=150)
nom = String(maxsize=150)
numero = Int()
associate_affaire = SubjectRelation("Affaire", cardinality="**")
associate_person = SubjectRelation("PersonBase")
......@@ -134,7 +134,7 @@ class PropertiesFromTC(TestCase):
)
def test_constraint_properties_1(self):
props_ref = {"max_size": 150, "required": False}
props_ref = {"maxsize": 150, "required": False}
self.assertEqual(
{"maxsize": 150, "__permissions__": self.expected_default_attr_perms, "order": 1},
properties_from(self.build_relation_definition(props_ref)),
......@@ -148,7 +148,7 @@ class PropertiesFromTC(TestCase):
)
def test_constraint_properties_3(self):
props_ref = {"vocabulary": ("aaa", "bbbb", "ccccc"), "required": False, "max_size": 20}
props_ref = {"vocabulary": ("aaa", "bbbb", "ccccc"), "required": False, "maxsize": 20}
relation_definition = self.build_relation_definition(props_ref)
props_ref["maxsize"] = 5
self.assertEqual(
......
......@@ -433,7 +433,7 @@ class SchemaLoaderModnamesTC(SchemaLoaderTC):
class BasePerson(EntityType):
firstname = String(vocabulary=("logilab", "caesium"), max_size=10)
firstname = String(vocabulary=("logilab", "caesium"), maxsize=10)
lastname = String(constraints=[StaticVocabularyConstraint(["logilab", "caesium"])])
......@@ -573,7 +573,7 @@ class SchemaLoaderTC2(TestCase):
def test_bad_int_size_constraint(self):
class Entity(EntityType):
attr = Int(max_size=40)
attr = Int(maxsize=40)
with self.assertRaises(BadSchemaDefinition) as cm:
build_schema_from_namespace(locals().items())
......@@ -585,7 +585,7 @@ class SchemaLoaderTC2(TestCase):
constraints=[StaticVocabularyConstraint(["ab", "abc"]), SizeConstraint(2)]
)
# "auto-fixed" when using:
# vocabulary=['ab', 'abc'], max_size=1)
# vocabulary=['ab', 'abc'], maxsize=1)
with self.assertRaises(BadSchemaDefinition) as cm:
schema = build_schema_from_namespace(locals().items())
......
......@@ -328,12 +328,11 @@ class AbstractTypedAttribute(SubjectRelation):
subclasses must provide a <entity_type> attribute to be instantiable
"""
@deprecation.argument_renamed(old_name="maxsize", new_name="max_size")
def __init__(
self,
metadata: Optional[Dict[str, "AbstractTypedAttribute"]] = None,
required: bool = False,
max_size: Optional[int] = None,
maxsize: Optional[int] = None,
formula=MARKER,
vocabulary: Optional[List[str]] = None,
unique: Optional[bool] = None,
......@@ -353,9 +352,9 @@ class AbstractTypedAttribute(SubjectRelation):
cardinality = "?1"
kwargs["cardinality"] = cardinality
# transform max_size into SizeConstraint
if max_size is not None:
_add_constraint(kwargs, SizeConstraint(max=max_size))
# transform maxsize into SizeConstraint
if maxsize is not None:
_add_constraint(kwargs, SizeConstraint(max=maxsize))
# formula
self.formula = formula
......@@ -489,12 +488,11 @@ class Interval(AbstractTypedAttribute):
# provides a RichString factory for convenience
@deprecation.attribute_renamed(old_name="maxsize", new_name="max_size")
def RichString(
default_format: str = "text/plain",
format_constraints: Optional[List[BaseConstraint]] = None,
required: bool = False,
max_size: Optional[int] = None,
maxsize: Optional[int] = None,
formula=MARKER,
vocabulary: Optional[List[str]] = None,
unique: Optional[bool] = None,
......@@ -516,7 +514,7 @@ def RichString(
default='text/rest', constraints=[FORMAT_CONSTRAINT])
content = String(fulltextindexed=True)
"""
format_args = {"default": default_format, "max_size": 50}
format_args = {"default": default_format, "maxsize": 50}
if format_constraints is None:
format_args["constraints"] = [FORMAT_CONSTRAINT]
......@@ -533,7 +531,7 @@ def RichString(
return String(
metadata=meta,
required=required,
max_size=max_size,
maxsize=maxsize,
formula=formula,
vocabulary=vocabulary,
unique=unique,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment