Skip to content
This repository was archived by the owner on May 30, 2022. It is now read-only.
This repository was archived by the owner on May 30, 2022. It is now read-only.

Incorrect flagging of duplicate argument #87

@ddutt

Description

@ddutt

I seem to be running into what seems an invalid enforcement. Nothing bad seems to happen (choices provided are correct, help string is correct and so on) if we skip the enforcement. So, I'm not sure if this is a bug with consequences I'm not spotting, or is it just a wrong check.

I have a class SqCommand whose class decorator takes a set of arguments that apply to all the subcommands of that class. So SqCommand represents a super command. I then define two subclasses of this SqCommand, lets say super1 and super2. Both their classes take arguments that apply to all subcommands of those two super commands. If I define an argument with the same name, say "state" for both super1 and super2, Nubia complains that I've defined a duplicate of the same variable, "state", This happens around line 161 in nubia/internal/typing/init.py. If I comment out that check, everything seems to work as expected.

I'm attaching a skeleton to explain what I'm seeing as the problem (state is flagged as a duplicate var). I've tried both command_pkgs and get_cmds() methods to register Super1 and Super2 and both have the same issue.

Thanks,

Dinesh

@argument('var1', desciption='var1')
class SqCommand:
    def __initi__(self, var1):
        self.var1 = var1
    
   @command('show')
    def show(self):
       do_something(self.var1)

@command('super1')
@argument('state', description='super1 state', choices=['a', 'b'])
class Super1(SqCommand):
    def __init__(self, state):
        self.state = state

   @command('show')
   def show(self):
        do_something(self.var1, self.state)

@command('super1')
@argument('state', description='super2 state', choices=['c', 'd'])
class Super2(SqCommand):
    def __init__(self, state):
        self.state = state

   @command('show')
   def show(self):
        do_something(self.var1, self.state)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions