我想知道处理与其他模块关联的未知类型的函数/方法的最佳方法是什么。请注意,我使用的是strict模式
例如,我有以下内容:
rooms: List[str] = list(mongo_client.devices.distinct("room"))
Run Code Online (Sandbox Code Playgroud)
mongo_client只是一个MongoClient从 导入的实例pymongo。VSCode 尖叫它不知道该distinct方法的类型:
Type of "distinct" is partially unknown
Type of "distinct" is "(key: Unknown, filter: Unknown = None, session: Unknown = None, **kwargs: Unknown) -> Unknown"PylancereportUnknownMemberType
Argument type is unknown
Argument corresponds to parameter "iterable" in function "__init__"PylancereportUnknownArgumentType
Run Code Online (Sandbox Code Playgroud)
我可以做什么:
reportUnknownMemberType pyrightconfig.json然而,虽然这会删除之前的警告,但它也会禁用我可能真正想要的警告# type: ignore带有该独特呼叫的线路;我通常讨厌像这样的无视评论,我不认为它“修复”任何东西你会怎么办?我不应该使用strict模式吗?该项目的大部分内容都是在激活严格模式的情况下编写的,以确保我不会遗漏任何内容。cast这是我能做的一些伎俩吗?
谢谢!
我有两个问题:
我在哪里可以找到 GraphSON 文件的基本格式,保证 gremlin 控制台成功加载?我正在尝试将 JSON(大约有 10-20 个字段)转换为另一个可以由 gremlin 查询的文件,但我实际上无法找到有关 graphson 格式保留的字段的任何相关信息,或者我应该如何处理 ID等等。我导出了他们提供的现代图形,它甚至不是一个有效的 JSON(多个 JSON 根元素),而是一个 JSON 列表 [1] 我还看到了像 outE、inE 这样的字段...创建?
如果我能够创建 JSON,那么在我启动它时,我应该在哪里告诉服务器将它加载为基础图?在配置文件中还是在脚本中?
谢谢!阿德里安
[1] https://pastebin.com/drwXhg5k
{"id":1,"label":"person","outE":{"created":[{"id":9,"inV":3,"properties":{"weight":0.4}}],"knows":[{"id":7,"inV":2,"properties":{"weight":0.5}},{"id":8,"inV":4,"properties":{"weight":1.0}}]},"properties":{"name":[{"id":0,"value":"marko"}],"age":[{"id":1,"value":29}]}}
{"id":2,"label":"person","inE":{"knows":[{"id":7,"outV":1,"properties":{"weight":0.5}}]},"properties":{"name":[{"id":2,"value":"vadas"}],"age":[{"id":3,"value":27}]}}
{"id":3,"label":"software","inE":{"created":[{"id":9,"outV":1,"properties":{"weight":0.4}},{"id":11,"outV":4,"properties":{"weight":0.4}},{"id":12,"outV":6,"properties":{"weight":0.2}}]},"properties":{"name":[{"id":4,"value":"lop"}],"lang":[{"id":5,"value":"java"}]}}
{"id":4,"label":"person","inE":{"knows":[{"id":8,"outV":1,"properties":{"weight":1.0}}]},"outE":{"created":[{"id":10,"inV":5,"properties":{"weight":1.0}},{"id":11,"inV":3,"properties":{"weight":0.4}}]},"properties":{"name":[{"id":6,"value":"josh"}],"age":[{"id":7,"value":32}]}}
{"id":5,"label":"software","inE":{"created":[{"id":10,"outV":4,"properties":{"weight":1.0}}]},"properties":{"name":[{"id":8,"value":"ripple"}],"lang":[{"id":9,"value":"java"}]}}
{"id":6,"label":"person","outE":{"created":[{"id":12,"inV":3,"properties":{"weight":0.2}}]},"properties":{"name":[{"id":10,"value":"peter"}],"age":[{"id":11,"value":35}]}}
Run Code Online (Sandbox Code Playgroud) 我正在使用 vis.js,我的任务之一是实现以下行为:当我选择一个节点时,该节点及其邻居必须突出显示。同时,所有其他节点必须具有“灰显”效果。看着 vis.js 展示,我看到了这个: https: //kenedict.com/networks/startups/,这正是我想要获得的。
问题是……如何轻松实现这种效果呢?我真的需要在图中的所有节点之间进行迭代并更改它们的颜色属性吗?
谢谢!