Title: PLS does not resolve base class expressions in correct scope · Issue #508 · microsoft/python-language-server · GitHub
Open Graph Title: PLS does not resolve base class expressions in correct scope · Issue #508 · microsoft/python-language-server
X Title: PLS does not resolve base class expressions in correct scope · Issue #508 · microsoft/python-language-server
Description: Consider the following Python code: class ContainerClass(): class BaseClass(object): def __init__(self, name): self.name = name class SubClass(BaseClass): def __init__(self): super().__init__('') The PLS analyzer logic incorrectly report...
Open Graph Description: Consider the following Python code: class ContainerClass(): class BaseClass(object): def __init__(self, name): self.name = name class SubClass(BaseClass): def __init__(self): super().__init__('') T...
X Description: Consider the following Python code: class ContainerClass(): class BaseClass(object): def __init__(self, name): self.name = name class SubClass(BaseClass): def __init__(self): super().__init__('...
Opengraph URL: https://github.com/microsoft/python-language-server/issues/508
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PLS does not resolve base class expressions in correct scope","articleBody":"Consider the following Python code:\r\n\r\n```\r\nclass ContainerClass():\r\n class BaseClass(object):\r\n def __init__(self, name):\r\n self.name = name\r\n\r\n class SubClass(BaseClass):\r\n def __init__(self): \r\n super().__init__('')\r\n```\r\n\r\nThe PLS analyzer logic incorrectly reports that `BaseClass` is referenced before being defined. In looking at the PLS code, `AnalysisUnit.AnalyzeWorker` is calling `EvaluateBaseClass` from within the scope of the subclass rather than its outer (containing) class.\r\n\r\nI think this can be fixed by modifying `AnalysisUnit.AnalyzeWorker` to temporarily set the scope of the ddg to the outer scope before calling `EvaluateBaseClass`. Something like this:\r\n```\r\n// Evaluate base classes in the outer scope.\r\nif (_outerUnit.Scope is InterpreterScope) {\r\n ddg.Scope = _outerUnit.Scope as InterpreterScope;\r\n}\r\nbases.Add(EvaluateBaseClass(ddg, classInfo, i, baseClassArg.Expression));\r\nddg.Scope = InterpreterScope;\r\n```\r\n","author":{"url":"https://github.com/erictraut","@type":"Person","name":"erictraut"},"datePublished":"2018-12-26T00:54:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/508/python-language-server/issues/508"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c41d60cd-589c-2369-eec6-33f025f3c71c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BCFA:111866:10DEA69:1628C2F:6A51A449 |
| html-safe-nonce | 5215fc83c8ed36e4d601d2847e9af4e101ffad6c6989cf994edaa899a6d3f1e9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0ZBOjExMTg2NjoxMERFQTY5OjE2MjhDMkY6NkE1MUE0NDkiLCJ2aXNpdG9yX2lkIjoiOTE3MTU0NjI2MTcxMDU0NTk5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c863f7b8966c1c17e830d33e2b4316376624a609a89e5f81968b9e5e357b489d |
| hovercard-subject-tag | issue:394059393 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/python-language-server/508/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d107975394fcc9b9bab6c58a6a0b526071fbca6376a4a0c41cec100bba6bd9b1/microsoft/python-language-server/issues/508 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d107975394fcc9b9bab6c58a6a0b526071fbca6376a4a0c41cec100bba6bd9b1/microsoft/python-language-server/issues/508 |
| og:image:alt | Consider the following Python code: class ContainerClass(): class BaseClass(object): def __init__(self, name): self.name = name class SubClass(BaseClass): def __init__(self): super().__init__('') T... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | erictraut |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/python-language-server git https://github.com/microsoft/python-language-server.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 145901977 |
| octolytics-dimension-repository_nwo | microsoft/python-language-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 145901977 |
| octolytics-dimension-repository_network_root_nwo | microsoft/python-language-server |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width