question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to best troubleshoot or fix NotImplementedExceptions()

See original GitHub issue

I’m trying to run this on a python project and am getting NotImplementedExceptions on some files when I use -r for a few of the subfolders. If I process the files by naming each as an argument instead of using -r, it processes without error.

The stack trace that I get most often is

System.NotImplementedException: The method or operation is not implemented.
   at Pytocs.Core.TypeInference.TypeTransformer.VisitAsync(AsyncStatement a)
   at Pytocs.Core.Syntax.AsyncStatement.Accept[T](IStatementVisitor`1 v)
   at Pytocs.Core.TypeInference.TypeTransformer.VisitSuite(SuiteStatement b)
   at Pytocs.Core.Syntax.SuiteStatement.Accept[T](IStatementVisitor`1 v)
   at Pytocs.Core.TypeInference.TypeTransformer.VisitClass(ClassDef c)
   at Pytocs.Core.Syntax.ClassDef.Accept[T](IStatementVisitor`1 v)
   at Pytocs.Core.TypeInference.TypeTransformer.VisitSuite(SuiteStatement b)
   at Pytocs.Core.Syntax.SuiteStatement.Accept[T](IStatementVisitor`1 v)
   at Pytocs.Core.TypeInference.TypeTransformer.VisitModule(Module m)
   at Pytocs.Core.TypeInference.AnalyzerImpl.LoadModule(Module ast)
   at Pytocs.Core.TypeInference.AnalyzerImpl.LoadFile(String path)
   at Pytocs.Core.TypeInference.AnalyzerImpl.LoadFileRecursive(String fullname)
   at Pytocs.Core.TypeInference.AnalyzerImpl.LoadFileRecursive(String fullname)
   at Pytocs.Core.TypeInference.AnalyzerImpl.Analyze(String path)
   at Pytocs.Cli.Program.Main(String[] args)

When debugging, its complaining about a method like the first async one (check_for_next_number_button) on line 26 in this example file

import logging
import string
from typing import Iterator
import attr
from this_project import BaseClass
from this_project.utils import MyContext

logger = logging.getLogger(__name__)

@attr.s(auto_attribs=True)
class SomeClass(BaseClass):
    remaining_numbers: Iterator[str] = attr.ib(init=False)
    current_number: str = attr.ib(init=False)

    def __attrs_post_init__(self):
        self.remaining_numbers = iter(string.ascii_uppercase)
        self.current_number = next(self.remaining_numbers)

    @property
    def next_number_xpath(self) -> str:
        xpath = "//a[./text()='{0}']".format(self.current_number)
        logger.debug("Generated XPath {0} in {1}"
                     .format(xpath, type(self).__name__))
        return xpath

    async def check_for_next_number_button(self,
                                         my_context: MyContext) -> bool:
        """ Some comment
        spanning multiple lines """
        return self.current_number != 'Z'

    async def get_next_result_number(self, my_context: MyContext):
        self.current_number = next(self.remaining_numbers)
        await super(SomeClass, self).get_next_result_number(
            my_context=my_context)

If I run it for the root of the project, I get similar errors but on Assign or Expr (i forget which). I tried copy/pasting the VisitAsync implementation from StatementTranslator to TypeTranslator but that just led me to another error so I figured I should just stop and ask a few questions.

What does the TypeAnalyzer used by the -r switch intend to do?

Is addressing the problems I’m seeing going to work by just wiring up the methods to accept (like the copy pasted VisitAsync)?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
uxmalcommented, Jun 12, 2022

Also, don’t be shy, and report any specific missing features so that I can update pytocs to match the ever changing python language

1reaction
uxmalcommented, Feb 28, 2019

To further answer your questions: the TypeAnalyzer attempts to infer the data types of arguments to Python defs, local variables, and class attributes. In the case of a function like

async def get_check_for_next_number():
    # code elided
   return self.current_number != 'Z'

the resulting C# types should be:

public async Task<bool> get_check_for_next_number() {
    // Code elided
    return this.current_number != 'Z';
}

The TypeAnalyzer should determine that get_check_for_next_number is an awaitable, and further deduce that the awaitable is returning a boolean value. This translates to Task<bool> in C#.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use of NotImplementedException
I'd say it's a good idea. Usually I see those exceptions thrown by skeleton code that is auto-generated from a form or diagram...
Read more >
NotImplementedException but already call the method in ...
If you call the method, and the only thing the method is doing is throwing an exception, then you'll get an exception... You...
Read more >
NotImplementedException Class (System)
Initializes a new instance of the NotImplementedException class with a specified error message and a reference to the inner exception that is the...
Read more >
How To Fix Not Implemented Exception in Explicit Interface ...
Unlock the power of Microsoft .NET Core with my engaging Udemy courses! For all the details and limited-time $9.99 pricing, scroll down to ......
Read more >
How do I solve the method is not implemented?
The idea is that the "not implemented exception" reminds you that you haven't written the code yet and makes it easy to locate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found