fastly / fastly-py

A Fastly API client for Python
https://pypi.org/project/fastly/
MIT License
77 stars 59 forks source link

NameError: name 'Service' is not defined #39

Closed joebeard closed 1 year ago

joebeard commented 5 years ago

This module seems to fail to function due to an unresolved import when installed under pipenv

To replicate, using pipenv:

Pipfile:

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]

[packages]
fastly = "==0.2.3"

[requires]
python_version = "3.7"

Steps to replicate:

jbeard@jbeard-desktop /tmp/fastly-py-test $ pipenv install
jbeard@jbeard-desktop /tmp/fastly-py-test $ pipenv run python
Python 3.7.3 (default, May  8 2019, 14:42:49) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from fastly import fastly
>>> api = fastly.API()
>>> api.authenticate_by_key('DUMMY')
>>> api.service('DUMMY')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/.venv/lib/python3.7/site-packages/fastly/fastly.py", line 33, in service
    return Service.find(self.conn, id=id)
NameError: name 'Service' is not defined
>>> 

I believe this can be fixed with an implict import statement in fastly.py:

from fastly.models import *
jacobbridges commented 4 years ago

Instead of

from fastly import fastly

Just do

import fastly
api = fastly.API()
Integralist commented 1 year ago

Closing this issue now we've published v1.0.0 https://pypi.org/project/fastly/