question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

exception with from __future__ annotations

See original GitHub issue

example:

from __future__ import annotations

import marshmallow_dataclass

@marshmallow_dataclass.dataclass
class C:
    s: str

result

AttributeError: 'str' object has no attribute '__dataclass_fields__'

I believe the problem is in _ _ init _ _.py:

    # Base types
    if typ in _native_to_marshmallow:
        return _native_to_marshmallow[typ](**metadata)

since type is ‘str’ instead of str, the base type isn’t found

marshmallow-dataclass==6.0.0c1
python==3.7.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
JamieMcKernanKaizencommented, Aug 12, 2021

Has there been any update on this? It still seems to be a bug that exists.

2reactions
AleksanderPawlakcommented, Dec 17, 2021

@lovasoa I’ve prepared improved version of this PR: https://github.com/lovasoa/marshmallow_dataclass/pull/54 here: https://github.com/lovasoa/marshmallow_dataclass/pull/170 All todos/fixme are resolved, could you please look at it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't import annotations from __future__ - Stack Overflow
If I use annotations, they are widely supported in 3.7, so no need for a future. If I run my code on an...
Read more >
Semshi produces errors with __future__ annotations #116
It's very useful and helpful. But, apparently, Semshi has issues with files containing the following line: from __future__ import annotations.
Read more >
__future__ — Future statement definitions — Python 3.11 ...
Else MandatoryRelease records when the feature became part of the language; in releases at or after that, modules no longer need a future...
Read more >
Function annotations — Python-Future documentation
Function annotations are a piece of syntax introduced in Python 3.0 that was not backported to Python 2.x. (See PEP 3107: http://www.python.org/dev/peps/pep- ...
Read more >
What are Python __future__ imports? - YouTube
Imports from the future !Python allows you to opt in to new features that are planned to change in future versions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found