• Login
Community
  • Login

Function Parameters Hint very Limited for Python

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 5 Posters 833 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    Ahmed Abuharthieh
    last edited by Aug 4, 2023, 4:19 PM

    Hello,
    I noticed that NPP’s function parameters hint is limited in Python in that it doesn’t show hints for functions outside of the basic built-ins like range() and other such functions.

    In Python IDLE, I can type random.random() from the random module and it will still give me function parameter hints.
    ced16652-2425-456a-a0bf-9841235c3115-image.png

    If I do the same in NPP, I dont get any function parameter hints. (random module was also imported here)
    6d29109d-f8b0-45d7-bb14-4701d3acbc2e-image.png
    Here is an example of the hints working just to show that it does work for functions like range()
    f597590c-7ccd-4a4e-8fac-2a3d61233073-image.png

    Is there a way for me to add this functionality so that I can get hints for built-in or even third-party modules?

    A M 2 Replies Last reply Aug 4, 2023, 4:30 PM Reply Quote 0
    • A
      Ahmed Abuharthieh @Ahmed Abuharthieh
      last edited by Ahmed Abuharthieh Aug 4, 2023, 6:35 PM Aug 4, 2023, 4:30 PM

      This might be a better example from Python IDLE
      fc611734-bce2-42d9-8b3f-708400132f84-image.png

      1 Reply Last reply Reply Quote 0
      • M
        Mark Olson
        last edited by Mark Olson Aug 4, 2023, 9:50 PM Aug 4, 2023, 9:41 PM

        @Ahmed-Abuharthieh
        The experience you get in IDLE and any other IDE comes from a language server . In other words, there is something in the background totally separate from the text editor itself that parses/interprets/compiles the document in real time as you are typing. The same is true of any other Python IDE you use, be it PyCharm, VSCode, etc., etc.

        Let me reiterate - what you are talking about is not a component of the text editor. The only responsibility of a text editor like Notepad++ is to deal with rendering of text, find/replace functionality, making sure documents are saved to hard drive without data loss, and in some cases providing syntax coloring.

        While there are various plugins to Notepad++ that can provide an IDE-like experience, the sort of thing you are asking for will almost certainly never be a core feature of Notepad++.

        BTW, the reason you get any hints at all in Notepad++ is just that Notepad++ has built-in config files that provide hints for a subset of the built-in functions. Unfortunately this approach is impossible to scale to the vast array of Python functions even in the standard library alone, and literally useless for parsing functions that you define within your own file.

        P 1 Reply Last reply Aug 4, 2023, 11:13 PM Reply Quote 3
        • P
          PeterJones @Mark Olson
          last edited by PeterJones Aug 4, 2023, 11:25 PM Aug 4, 2023, 11:13 PM

          @Mark-Olson said in Function Parameters Hint very Limited for Python:

          Let me reiterate - what you are talking about is not a component of the text editor.

          I agree that the language server is not a component of the text editor. But if the text editor has an LSP client, then it can access that information and present it.

          Notepad++ does not currently have an LSP client built in (though that would be nice, I doubt the developer is going to do that)… but there are a couple of Notepad++ users who have alpha/beta versions of LSP clients as plugins for Notepad++ – you can just search the forum for LSP and you will probably find a link to them; I don’t know if they will be functional enough for you yet or not.

          addendum: here’s a post that links to kered13’s LSP plugin and ekopalypse’s LSP plugin .

          1 Reply Last reply Reply Quote 2
          • A
            Ahmed Abuharthieh
            last edited by Aug 5, 2023, 1:17 AM

            @Mark-Olson @PeterJones

            Thank you both for your insight. I was mostly curious if there was some way I could expand the number of functions the hints work for.

            I think I better understand the scope of how that feature works so I will probably continue on with Notepad++ as is for now (since it’s already very good for my use case).

            Best,
            Ahmed

            R 1 Reply Last reply Aug 5, 2023, 2:19 AM Reply Quote 0
            • M
              mpheath @Ahmed Abuharthieh
              last edited by Aug 5, 2023, 2:06 AM

              @Ahmed-Abuharthieh

              Give generate-python-3-api a try which I authored.

              Change the options or suggest initially to remain with default options within gen_python_3_api.py and then run it with Python to write out 4 files. Suggest to run the script in an empty directory so it will not overwrite any files with the preset names.

              One of the files will be named python3.xml. This file can be renamed to python.xml and can replace Notepad++'s autoCompletion\python.xml.

              The python.xml that comes with Notepad++ v8.5.4 is 61KB which I replaced with the generated python.xml which is 1418KB, using Python v3.11.4. The file size could increase if site packages, … are enabled in the scripts options.

              R A 2 Replies Last reply Aug 5, 2023, 2:28 AM Reply Quote 4
              • R
                rdipardo @Ahmed Abuharthieh
                last edited by Aug 5, 2023, 2:19 AM

                This post is deleted!
                1 Reply Last reply Reply Quote 1
                • R
                  rdipardo @mpheath
                  last edited by Aug 5, 2023, 2:28 AM

                  Python function hints come from this XML configuration file . You will find it at one of the following places on your system:

                  • %ProgramFiles%\Notepad++\autoCompletion\python.xml (64-bit, fully-installed Notepad++)
                  • %ProgramFiles(x86)%\Notepad++\autoCompletion\python.xml (32-bit, fully-installed Notepad++)
                  • $(Portable_Installation_Dir)\autoCompletion\python.xml (any portable Notepad++)

                  Additional functions can be added by editing the file, e.g. (note that stands for a line break, so the description text follows on a new line, and > is a named entity that will render as >):

                  Or,

                  Give generate-python-3-api a try

                  My bad for posting just behind the better answer!

                  1 Reply Last reply Reply Quote 1
                  • A
                    Ahmed Abuharthieh @mpheath
                    last edited by Aug 5, 2023, 4:40 PM

                    @mpheath
                    Sounds good, I will give it a try. Thank you for your help

                    1 Reply Last reply Reply Quote 1
                    7 out of 9
                    • First post
                      7/9
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors