From 5e261d41ea7a64055926c9decb228f1521761ee0 Mon Sep 17 00:00:00 2001 From: Steve Phelps Date: Sun, 5 Nov 2023 21:13:07 +0000 Subject: [PATCH] dummy vars renamed __x__ for compatibility with pyright --- .pylintrc | 4 ++-- llm_cooperation/experiments/dilemma.py | 8 ++++---- llm_cooperation/experiments/principalagent.py | 4 ++-- llm_cooperation/gametypes/__init__.py | 2 +- llm_cooperation/gametypes/oneshot.py | 2 +- llm_cooperation/gametypes/repeated.py | 2 +- tests/test_alternating.py | 2 +- tests/test_experiments.py | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.pylintrc b/.pylintrc index c486d3a..3c70844 100644 --- a/.pylintrc +++ b/.pylintrc @@ -623,7 +623,7 @@ callbacks=cb_, # A regular expression matching the name of dummy variables (i.e. expected/var to # not be used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ +dummy-variables-rgx=_+$|(__[a-zA-Z0-9_]*[a-zA-Z0-9]+__$)|dummy|^ignored_|^unused_ # Argument names that match this expression will be ignored. ignored-argument-names=_.*|^ignored_|^unused_ @@ -636,4 +636,4 @@ init-import=no redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io [MASTER] -disable=C0114,C0116,C0115,R0902,R0913,R1735,R0903,C0103,R1705,W0621 +disable=C0114,C0116,C0115,R0902,R0913,R1735,R0903,C0103,R1705,W0621,R0801 diff --git a/llm_cooperation/experiments/dilemma.py b/llm_cooperation/experiments/dilemma.py index abd8077..dd077d3 100755 --- a/llm_cooperation/experiments/dilemma.py +++ b/llm_cooperation/experiments/dilemma.py @@ -102,14 +102,14 @@ def round_instructions() -> str: # pylint: disable=unused-argument def strategy_defect( - state: GameState[DilemmaChoice, ChainOfThoughtCondition, str], **_kwargs: bool + state: GameState[DilemmaChoice, ChainOfThoughtCondition, str], **__kwargs__: bool ) -> DilemmaChoice: return Defect # pylint: disable=unused-argument def strategy_cooperate( - state: GameState[DilemmaChoice, ChainOfThoughtCondition, str], **_kwargs: bool + state: GameState[DilemmaChoice, ChainOfThoughtCondition, str], **__kwargs__: bool ) -> DilemmaChoice: return Cooperate @@ -117,7 +117,7 @@ def strategy_cooperate( def strategy_t4t( initial_choice: DilemmaChoice, state: GameState[DilemmaChoice, ChainOfThoughtCondition, str], - **_kwargs: bool, + **__kwargs__: bool, ) -> DilemmaChoice: if len(state.messages) == 2: return initial_choice @@ -152,7 +152,7 @@ def choice_from_str(choice: str) -> DilemmaChoice: raise ValueError(f"Cannot determine choice from {choice}") -def extract_choice_pd(completion: Completion, **_kwargs: bool) -> DilemmaChoice: +def extract_choice_pd(completion: Completion, **__kwargs__: bool) -> DilemmaChoice: regex: str = r".*project (blue|green)" choice_regex: str = f"choice:{regex}" logger.debug("completion = %s", completion) diff --git a/llm_cooperation/experiments/principalagent.py b/llm_cooperation/experiments/principalagent.py index 7236a64..3882599 100644 --- a/llm_cooperation/experiments/principalagent.py +++ b/llm_cooperation/experiments/principalagent.py @@ -107,11 +107,11 @@ def extract_choice_pa(completion: Completion) -> PAChoice: raise ValueError(f"Cannot determine choice from {completion}") -def payoffs_pa(_choice: PAChoice) -> float: +def payoffs_pa(__choice__: PAChoice) -> float: return np.nan -def compute_freq_pa(_choice: PAChoice) -> float: +def compute_freq_pa(__choice__: PAChoice) -> float: return np.nan diff --git a/llm_cooperation/gametypes/__init__.py b/llm_cooperation/gametypes/__init__.py index da053f6..80b3f98 100644 --- a/llm_cooperation/gametypes/__init__.py +++ b/llm_cooperation/gametypes/__init__.py @@ -2,7 +2,7 @@ from typing import List, Protocol, Tuple -from openai_pygenerator import Completer, Completion, History, user_message +from openai_pygenerator import Completer, Completion, user_message from llm_cooperation import PT, RT, ModelSetup, PT_contra, RT_contra, completer_for diff --git a/llm_cooperation/gametypes/oneshot.py b/llm_cooperation/gametypes/oneshot.py index 9882454..f23db9f 100644 --- a/llm_cooperation/gametypes/oneshot.py +++ b/llm_cooperation/gametypes/oneshot.py @@ -102,7 +102,7 @@ def generate_samples( participant_condition: PT, ) -> Iterable[Tuple[float, float, Optional[CT], List[str]]]: # pylint: disable=R0801 - for _i in range(num_samples): + for __i__ in range(num_samples): conversation = play_game( role_prompt=prompt, participant_condition=participant_condition, diff --git a/llm_cooperation/gametypes/repeated.py b/llm_cooperation/gametypes/repeated.py index 8111f73..bb3e551 100644 --- a/llm_cooperation/gametypes/repeated.py +++ b/llm_cooperation/gametypes/repeated.py @@ -215,7 +215,7 @@ def generate_samples( game_setup: GameSetup[CT, PT, RT], ) -> Iterable[Tuple[float, float, Optional[List[Choices[CT]]], List[str]]]: # pylint: disable=R0801 - for _i in range(measurement_setup.num_samples): + for __i__ in range(measurement_setup.num_samples): conversation = play_game( partner_strategy=partner_strategy, participant_condition=condition, diff --git a/tests/test_alternating.py b/tests/test_alternating.py index 4f6b553..9564b7e 100644 --- a/tests/test_alternating.py +++ b/tests/test_alternating.py @@ -30,7 +30,7 @@ def test_analyse_round( expected_choices: Choices, alternating_history, ): - _scores, choices = alternating.analyse_round( + __scores__, choices = alternating.analyse_round( i, alternating_history, payoffs_ultimatum, extract_choice_ultimatum ) assert choices == expected_choices diff --git a/tests/test_experiments.py b/tests/test_experiments.py index 93cea06..f77d905 100644 --- a/tests/test_experiments.py +++ b/tests/test_experiments.py @@ -33,7 +33,7 @@ def test_run_and_record_experiment(mocker): name = "test_experiment" run_and_record_experiment( name, - run=lambda _setup, _n: results_mock, + run=lambda __setup__, __n__: results_mock, model_setup=DEFAULT_MODEL_SETUP, sample_size=DEFAULT_SAMPLE_SIZE, )