BrianGladman / gmpy2

GNU Lesser General Public License v3.0
10 stars 8 forks source link

pycharm inspection "Unexpected argument" for gmpy2.mpz(...) #8

Closed brubsby closed 1 year ago

brubsby commented 1 year ago

I'm unsure exactly what's causing this, but pycharm 2022.3 community edition always seems to complain about passing a parameter to gmpy2.mpz, e.g. gmpy2.mpz(123456789) or gmpy2.mpz("123456789"). And there's no way from the instance of the inspection error to ignore it. So I assume there's something that can be done from the library side (if not a further buried option on the client side I've yet to find). If I had to warrant a guess, it's finding the signature with no parameter passed and assuming you can't pass a positional argument ever.

The code always runs fine but the inspection just complains and clutter's up the screen, and I don't want to disable this specific inspection as it is useful.

brubsby commented 1 year ago

I have however found that it seems like this inspection is built from the documentation, as this is the code it renders for the implementation of gmpy2.mpz reads:

    def __init__(self): # real signature unknown; restored from __doc__
        pass

Perhaps this can be alleviated by updating the docs to have the documentation be more "parseable"? If it's grabbing it from here:

    """
    mpz() -> mpz(0)

         If no argument is given, return mpz(0).

    mpz(n) -> mpz

         Return an 'mpz' object with a numeric value 'n' (truncating n
         to its integer part if it's a Fraction, 'mpq', float or 'mpfr').

    mpz(s[, base=0]):

         Return an 'mpz' object from a string 's' made of digits in the
         given base.  If base=0, binary, octal, or hex Python strings
         are recognized by leading 0b, 0o, or 0x characters, otherwise
         the string is assumed to be decimal. Values for base can range
         between 2 and 62.
    """

Maybe the second paragraph needs to go first? Just a guess.

This isn't annoying to me enough to where I want to struggle with building and deploying gmpy2 myself, but it seems easy enough for a maintainer to fix.

brubsby commented 1 year ago

Whoops I think I may have the wrong repo.

BrianGladman commented 1 year ago

Hi @brubsby You will need to report this at the primary repository for GMPY which is at https://github.com/aleaxit/gmpy This repository jut holds a clone of the master with minor changes for my own benefit.