Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
fix: linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukarade committed Mar 17, 2024
1 parent 705a09e commit 3074f8d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import builtins
import dataclasses
from typing import Tuple, Dict, List

import astroid
from astroid.helpers import safe_infer
Expand Down Expand Up @@ -509,16 +510,20 @@ def _find_target_references(self,

return result_target_reference

def _resolve_references(self):
def _resolve_references(self) -> tuple[dict[str, list[ReferenceNode]], dict[NodeID, Reasons]]:
"""
Resolve all references in a module.
This function is the entry point for the reference resolving.
It calls all other functions that are needed to resolve the references.
First, get the module data for the given (module) code.
Then call the functions to find all references (call, target in the module.
"""
Returns
-------
tuple[dict[NodeID, list[ReferenceNode]], dict[NodeID, Reasons]]
The resolved references and the raw reasons for the functions.
"""
raw_reasons: dict[NodeID, Reasons] = {}
call_references: dict[str, list[ReferenceNode]] = {}
value_references: dict[str, list[ReferenceNode]] = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class NonLocalVariableRead(Read):
"""

symbol: GlobalVariable | ClassVariable | InstanceVariable | Import
origin: Symbol = field(default=None)
origin: Symbol | None = field(default=None)

def __hash__(self) -> int:
return hash(str(self))
Expand All @@ -198,7 +198,7 @@ class FileRead(Read):
"""

source: Expression | None = None # TODO: this should never be None
origin: Symbol = field(default=None)
origin: Symbol | None = field(default=None)

def __hash__(self) -> int:
return hash(str(self))
Expand Down Expand Up @@ -226,7 +226,7 @@ class NonLocalVariableWrite(Write):
"""

symbol: GlobalVariable | ClassVariable | InstanceVariable | Import
origin: Symbol = field(default=None)
origin: Symbol | None = field(default=None)

def __hash__(self) -> int:
return hash(str(self))
Expand All @@ -249,7 +249,7 @@ class FileWrite(Write):
"""

source: Expression | None = None
origin: Symbol = field(default=None)
origin: Symbol | None = field(default=None)

def __hash__(self) -> int:
return hash(str(self))
Expand Down Expand Up @@ -279,7 +279,7 @@ class UnknownCall(Unknown):
"""

expression: Expression
origin: Symbol = field(default=None)
origin: Symbol | None = field(default=None)

def __hash__(self) -> int:
return hash(str(self))
Expand All @@ -303,7 +303,7 @@ class NativeCall(Unknown): # ExternalCall
"""

expression: Expression
origin: Symbol = field(default=None)
origin: Symbol | None = field(default=None)

def __hash__(self) -> int:
return hash(str(self))
Expand Down Expand Up @@ -331,7 +331,7 @@ class CallOfParameter(Unknown): # ParameterCall
"""

expression: Expression
origin: Symbol = field(default=None)
origin: Symbol | None = field(default=None)

def __hash__(self) -> int:
return hash(str(self))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class ModuleAnalysisResult:
resolved_references: dict[str, list[ReferenceNode]] = field(default_factory=dict)
raw_reasons: dict[NodeID, Reasons] = field(default_factory=dict)
classes: dict[str, ClassScope] = field(default_factory=dict)
call_graph_forest: CallGraphForest = None
call_graph_forest: CallGraphForest | None = None


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@


# TODO: change these to data folder
def test_run_api_command_safe_ds():
def test_run_api_command_safe_ds() -> None:
_run_api_command("safe-ds",
Path(r"C:\Users\Lukas Radermacher\AppData\Local\pypoetry\Cache\virtualenvs\library-analyzer-FK1WveJV-py3.11\Lib\site-packages\safeds"),
Path(r"C:\Users\Lukas Radermacher\Desktop\Results"),
DocstringStyle.NUMPY
)


def test_run_api_command_small_module():
def test_run_api_command_small_module() -> None:
_run_api_command("test_module",
Path(r"C:\Users\Lukas Radermacher\Desktop\Results\Tests"),
Path(r"C:\Users\Lukas Radermacher\Desktop\Results\Tests"),
Expand Down

0 comments on commit 3074f8d

Please sign in to comment.