Why is this class returning an error?

This is the code:

import lupa, os

class runDirectory(lupa.LuaRuntime):
  def __init__(self, directory):
    super().__init__()
    
    if os.path.exists(directory):
      if os.path.isfile(directory):
        raise Exception("'" + directory + "' is file. Argument should be directory")
      elif os.path.isdir(directory):
        pass
      else:
        raise Exception("Unknown error occured when checking directory validity")
    else:
      raise FileNotFoundError("File/Directory does not exist")
    
    allfiles =  os.listdir(dir)
    for file in allfiles:
      with open(file, "r") as f:
        self.eval(f.read())

Here is the error it returns:

luaInterpreter.runDirectory(directory="game/serverScriptStorage/langtypeLua")
File "lupa/lua54.pyx", line 268, in lupa.lua54.LuaRuntime.__cinit__
TypeError: __cinit__() got an unexpected keyword argument 'directory'

Can you give me a link to the Repl so I can help you better? Thanks

that’s a very interesting error because… the code never calls luaInterpreter

2 Likes

I agree with @bigminiboss so please share the repl, this I would really love to see (and finally have time ti spent on ask again)

2 Likes

It calls the class but from a different file

1 Like

here is the repl link:
[https://replit.com/@m1dnightdev/Uni3D?v=1]

1 Like