How to best troubleshoot or fix NotImplementedExceptions()
See original GitHub issueI’m trying to run this on a python project and am getting NotImplementedException
s 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:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Also, don’t be shy, and report any specific missing features so that I can update pytocs to match the ever changing python language
To further answer your questions: the
TypeAnalyzer
attempts to infer the data types of arguments to Pythondef
s, local variables, and class attributes. In the case of a function likethe resulting C# types should be:
The
TypeAnalyzer
should determine thatget_check_for_next_number
is anawaitable
, and further deduce that theawaitable
is returning a boolean value. This translates toTask<bool>
in C#.