Как я могу устранить эту ошибку круговой ссылки? Навык Alexa

#python

Вопрос:

Привет сообществу Python!

Я пишу навык Alexa для хакатона (у меня есть разрешение на поиск внешней помощи) и столкнулся с ошибкой круговой ссылки.

Я не видел ни одного в подобном случае, так что вот мой код.

 from flask import Flask
from ask_sdk_core.skill_builder import SkillBuilder
from flask_ask_sdk.skill_adapter import SkillAdapter
import intents
import identityDB

# Register the intents with the SkillBuilder. Intents are defined in intents.py.
# The SkillBuilder object acts as the entry point for your skill, routing all request and response
# payloads to the handlers in intents.py. Make sure any new handlers or interceptors you've
# defined are included below. The order matters - they're processed top to bottom.
sb = SkillBuilder()
sb.add_request_handler(intents.LaunchRequestHandler())
sb.add_request_handler(intents.HelpIntentHandler())
sb.add_request_handler(intents.CancelOrStopIntentHandler())
sb.add_request_handler(intents.HelloWorldIntentHandler())
sb.add_request_handler(intents.SessionEndedRequestHandler())
sb.add_request_handler(intents.RainbowIdentityIntentHandler())
sb.add_request_handler(intents.IntentReflectorHandler()) # Register this intent last!

app = Flask(__name__)
skill_id = 'amzn1.ask.skill.7ad5f0f1-09c1-4d46-90b1-2ffac8a0d980'
identityDB.show_keys()

skill_adapter = SkillAdapter(
  skill=sb.create(), 
  skill_id=skill_id, app=app
  )

@app.route("/", methods=["GET", "POST"])
def invoke_skill():
    return skill_adapter.dispatch_request()

app.run('0.0.0.0', port=443)
 

Вот мое identityDB.py досье:

 from replit import db
from identity import Identity

les = Identity()
les.name = "Lesbian"
les.description = "Attraction exclusively to other women by a woman. "

gay = Identity()
gay.name = "Gay"
gay.description = "Attraction exclusively to other men by a man."


tri = Identity()
tri.name = "Trixic"
tri.description = "Exclusive attraction to women by non binary people."


orb = tri
orb.name = "Orbisian"


tor = Identity()
tor.name =  "Toric"
tri.description = "Exclusive attraction to men by non binary people."
tor.id = "tor"

quad = tor
quad.name = "Quadrisian"

ace = Identity()
ace.name = "Asexual"
ace.description = "Umbrella term for not experiencing or having a non-conventional form of experiencing sexual attraction."

aro = Identity()
ace.name = "Aromantic"
ace.description = "Umbrella term for not experiencing or having a non-conventional form of experiencing romantic attraction."

tra = Identity()
tra.name = "Transgender"
tra.description = "Not identifying with your assigned gender at birth. Umbrella term."

non = Identity()
non.name = "Nonbinary"
non.description = "Not identifyimg with your assigned gender at birth. Umbrella term."

dmb = Identity()
dmb.name = "Demiboy"
dmb.description = "A gender identity where you experience being mostly a boy or partly a boy, but not fully."

dmg = Identity()
dmg.name = "Demigirl"
dmg.description = "A gender identity where you experience being mostly a girl or partly a girl, but not fully."

dme = Identity()
dme.name = "Demigender"
dme.description = "A gender identity where you experience being mostly a certain or partly a certain gender, but not fully."

lir = Identity()
lir.name = "Lithroromantic"
lir.description = "Experiencing romantic attraction but losing it at any sign of reciprocation."

lis = Identity()
lis.name = "Lithrosexual"
lis.description = "Experiencing sexual attraction but losing it at any sign of reciprocation."

akr = lir
akr.name = "Akoiromantic"

aks = lis
lis.name = "Akoisexual"

age = Identity()
age.name = "Agender"
age.description = "Lack of gender"
# Attraction
db[0] = les
db[1] = gay
db[2] = tri
db[3] = orb
db[4] = tor
db[5] = quad
db[6] = ace
db[7] = aro
# Gender
db[8] = tra
db[9] = non
db[10] = dmb
db[11] = dmg
db[12] = dme
db[13] = "xeno"
db[14] = "xenic"
# agender
# genderflux
# genderfluid
# Ace/Aro spec
db[15] = lir
db[16] = lis
db[17] = akr
db[18] = aks






def show_keys():
  keys = db.keys()
  for key in keys:
    print(key)

def get_identity(name):
  db.get(name)

 

Ошибка заключается в следующем:

 Traceback (most recent call last):
  File "main.py", line 5, in <module>
    import identityDB
  File "/home/runner/Rainbowlexa/identityDB.py", line 76, in <module>
    db[0] = les
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/database/database.py", line 491, in __setitem__
    self.set(key, value)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/database/database.py", line 500, in set
    self.set_raw(key, _dumps(value))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/database/database.py", line 56, in dumps
    return json.dumps(val, separators=(",", ":"), cls=DBJSONEncoder)
  File "/usr/lib/python3.8/json/__init__.py", line 234, in dumps
    return cls(
  File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
ValueError: Circular reference detected
 

Комментарии:

1. В обратной трассировке содержится информация о файлах и номерах строк, участвующих в циклической ссылке. Пожалуйста, отредактируйте свой вопрос, чтобы включить его.

2. Будем делать. Спасибо!

3. Ух ты. Оказывается, это был другой файл. Включу сейчас.

4. @BoarGules Готово!