Python keep asking argument which is not present anymore

Caejat

Newbie
Jan 21, 2022
51
47
Hi,

I'm trying working in Ren'Py and I found something very weird. In very early stage I defined the class:

Code:
init python:
    class Person:
        def __init__(self, character, name):
            self.ch = character
            self.name = name
but later I realized, I don't need a name argument in that class, because I provide it in character argument, so I delete it and now the class looks like this:

Code:
init python:
    class Person:
        def __init__(self, character):
            self.ch = character
But now, and this is the weird part, when I instantiate the class:

Code:
default test = Person(Character("Test"))
It keeps throwing me an error:

Code:
TypeError: __init__() missing 1 required positional argument: 'name'
And from my understanding, it wants 'name' argument, but I already delete it from the class, so I don't understand how it can still want it. When I try something like this:

Code:
default test = Person(Character("Test"), "test")
It works just fine and it doesn't make any sense to me and I'm really confused by this. Is there some way to reset the class or something ?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,398
15,312
but later I realized, I don't need a name argument in that class, because I provide it in character argument, so I delete it [...]
Code:
TypeError: __init__() missing 1 required positional argument: 'name'
How do you deleted it exactly ?
As much as Ren'Py can give a memory to Python, there's a limit to this, and class definition aren't part of it. There's the cache, but its expected to be rebuilt with every start and, more important, to not replace a defined function or class. Therefore the class "Person" is still defined with a __init__ meta method that have a "name" argument.

My guess is that you deleted the rpy file, but not the rpyc one.
 

Caejat

Newbie
Jan 21, 2022
51
47
How do you deleted it exactly ?
I delete it from the file as I mentioned in the post.. the class now looks like in the second code of the post, but Ren'Py still act like it's the first version..

My guess is that you deleted the rpy file, but not the rpyc one.
I already tried to delete both files, run Ren'Py without them, but it still act like the files are there. I'm totally perplexed by this, I never encounter with a such persistant cache..
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,398
15,312
I already tried to delete both files, run Ren'Py without them, but it still act like the files are there. I'm totally perplexed by this, I never encounter with a such persistant cache..
And there isn't such persistent cache in Ren'Py. There's a backup directory, but from Ren'Py size it's write only, and as I said the bytecode cache is supposed to be rebuilt at each start, during the AST creation in memory, therefore it shouldn't be it either.

The second most evident answer, especially if you deleted both the rpy and rpyc file, is that you defined the class twice.
 

Caejat

Newbie
Jan 21, 2022
51
47
The second most evident answer, especially if you deleted both the rpy and rpyc file, is that you defined the class twice.
Nope, I checked that, I have nothing declared twice. I checked every possible thing I could think of. I even deleted cache folder and even classes folder where all my classes were, but nothing helped. Maybe I missunderstood the error message, but when I add the second parameter to that Person class, then it's working. And I can't add nothing more to that class, Ren'Py just doesn't care, it acts like the file is cached or something.

I really can't understand what can be wrong. I have folder named 'classes' where is the file 'person.rpy' and this is the whole content of that file:
Code:
init python:
    class Person:
        def __init__(self, character):
            self.ch = character
and I called it from 'variables.rpy' which is in the root directory of the game. I was thinking, that I'm missing label in that file before "init python:" line, but even if I added the label in, nothing changed.
 

Caejat

Newbie
Jan 21, 2022
51
47
Ok, i finally figured it out where the problem was. It was in VS Code, more precisely in the ".vscode" folder, where I have "Settings.json" file and in it I have a few lines for excluding some files to have more cleaner workspace. For some reason I had an extra line in there and it was causing the problem.

.vscode/Settings.json:
Code:
{
     "files.exclude": {
         "**/*.rpyc": true,
         "**/*.rpa": true,
         "**/*.rpymc": true,
         "**/cache/": true
     }
}
and the line in question was:
Code:
"**/cache/": true
After deleting this line, everything was resolved.