Open
Description
Version: pip 0.1.16
Sometimes the ordering of classes in the generated python is improper so that base classes appear after derived classes that require them. Seems to be a function of the number of classes declared in the pkl
? If I declare 7 classes and 1 extends
, the ordering is incorrect. With 6 classes and 1 extends
, the ordering is correct.
== WORKS
// test.pkl
open class A1 {}
open class A2 {}
open class A3 {}
open class A4 {}
open class A5 {}
open class A6 {}
// open class A7 {} <====== generating this breaks class declaration ordering
class B1 extends A1{}
test_pkl.py
:
# Code generated from Pkl module `test`. DO NOT EDIT.
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Dict, List, Literal, Optional, Set, Union
import pkl
@dataclass
class A6:
_registered_identifier = "test#A6"
@dataclass
class A5:
_registered_identifier = "test#A5"
@dataclass
class A4:
_registered_identifier = "test#A4"
@dataclass
class A3:
_registered_identifier = "test#A3"
@dataclass
class A2:
_registered_identifier = "test#A2"
@dataclass
class A1:
_registered_identifier = "test#A1"
@dataclass
class B1(A1):
_registered_identifier = "test#B1"
@dataclass
class test:
_registered_identifier = "test"
@classmethod
def load_pkl(cls, source):
# Load the Pkl module at the given source and evaluate it into `test.Module`.
# - Parameter source: The source of the Pkl module.
config = pkl.load(source, parser=pkl.Parser(namespace=globals()))
return config
== DOES NOT WORK
// test.pkl
open class A1 {}
open class A2 {}
open class A3 {}
open class A4 {}
open class A5 {}
open class A6 {}
open class A7 {}
class B1 extends A1{}
test_pkl.py
:
# Code generated from Pkl module `test`. DO NOT EDIT.
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Dict, List, Literal, Optional, Set, Union
import pkl
@dataclass
class B1(A1):
_registered_identifier = "test#B1"
@dataclass
class A7:
_registered_identifier = "test#A7"
@dataclass
class A6:
_registered_identifier = "test#A6"
@dataclass
class A5:
_registered_identifier = "test#A5"
@dataclass
class A4:
_registered_identifier = "test#A4"
@dataclass
class A3:
_registered_identifier = "test#A3"
@dataclass
class A2:
_registered_identifier = "test#A2"
@dataclass
class A1:
_registered_identifier = "test#A1"
@dataclass
class test:
_registered_identifier = "test"
@classmethod
def load_pkl(cls, source):
# Load the Pkl module at the given source and evaluate it into `test.Module`.
# - Parameter source: The source of the Pkl module.
config = pkl.load(source, parser=pkl.Parser(namespace=globals()))
return config