dvf / blockchain

A simple Blockchain in Python
MIT License
7.81k stars 2.75k forks source link

Docker Container Fails to Run #29

Closed shubhamoy closed 7 years ago

shubhamoy commented 7 years ago

I tried to run the docker container after a successful build and ran into this error:

Traceback (most recent call last):
  File "/app/blockchain.py", line 12, in <module>
    class Blockchain:
  File "/app/blockchain.py", line 135, in Blockchain
    def last_block(self) -> Dict[str: Any]:
  File "/usr/local/lib/python3.6/typing.py", line 682, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.6/typing.py", line 1106, in __getitem__
    params = tuple(_type_check(p, msg) for p in params)
  File "/usr/local/lib/python3.6/typing.py", line 1106, in <genexpr>
    params = tuple(_type_check(p, msg) for p in params)
  File "/usr/local/lib/python3.6/typing.py", line 374, in _type_check
    raise TypeError(msg + " Got %.100r." % (arg,))
TypeError: Parameters to generic types must be types. Got slice(<class 'str'>, typing.Any, None).

Please help. TIA

pinnamur commented 7 years ago

I'm seeing the same error. It is triggered by latest merged PR.

floscha commented 7 years ago

Like the traceback suggests, the error is caused by a typo in line 135. Instead of def last_block(self) -> Dict[str: Any]: this line should be def last_block(self) -> Dict[str, Any]:.

Also, for this fix to work, you have to change the Dockerfile from pulling the GitHub repo to using your local code. So simply comment out this line: && git clone https://github.com/dvf/blockchain.git /app \ and insert COPY blockchain.py Pipfile /app/ before the RUN block.

Then you should be able to build and run the Dockerfile as usual.

shubhamoy commented 7 years ago

Thanks a ton :) It worked like charm!

Endogen commented 7 years ago

There is already a PR for that: #19 It's just that @dvf didn't merge it yet