Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions 16 Lib/dataclasses.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
import types
from copy import deepcopy
import collections
import inspect

__all__ = ['dataclass',
Expand Down Expand Up @@ -448,11 +447,11 @@ def _set_attribute(cls, name, value):


def _process_class(cls, repr, eq, order, hash, init, frozen):
# Use an OrderedDict because:
# - Order matters!
# - Derived class fields overwrite base class fields, but the
# order is defined by the base class, which is found first.
fields = collections.OrderedDict()
# Now that dicts retain insertion order, there's no reason to use
# an ordered dict. I am leveraging that ordering here, because
# derived class fields overwrite base class fields, but the order
# is defined by the base class, which is found first.
fields = {}

# Find our base classes in reverse MRO order, and exclude
# ourselves. In reversed order so that more derived classes
Expand Down Expand Up @@ -612,7 +611,8 @@ def fields(class_or_instance):
except AttributeError:
raise TypeError('must be called with a dataclass type or instance')

# Exclude pseudo-fields.
# Exclude pseudo-fields. Note that fields is sorted by insertion
# order, so the order of the tuple is as the fields were defined.
return tuple(f for f in fields.values() if f._field_type is _FIELD)


Expand Down Expand Up @@ -735,7 +735,7 @@ class C(Base):
# Copy namespace since we're going to mutate it.
namespace = namespace.copy()

anns = collections.OrderedDict()
anns = {}
for item in fields:
if isinstance(item, str):
name = item
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.