From 707696689d6706c46b8c3a807229ff6d22fa2e6a Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Tue, 27 May 2025 21:38:15 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`og-test?= =?UTF-8?q?-feature`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @omar-coderabbitai. * https://github.com/omar-coderabbitai/og-test-jira-uno/pull/2#issuecomment-2914124862 The following files were modified: * `weather-app.py` --- weather-app.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/weather-app.py b/weather-app.py index 5f77bdb..bfc2948 100644 --- a/weather-app.py +++ b/weather-app.py @@ -2,16 +2,14 @@ def get_temperature(city_name, api_key): """ - Fetches the current temperature in Fahrenheit for a given U.S. city - using the OpenWeatherMap API. - - Parameters: - city_name (str): The name of the U.S. city. - api_key (str): Your OpenWeatherMap API key. - + Retrieves the current temperature in Fahrenheit for a specified U.S. city using the OpenWeatherMap API. + + Args: + city_name: Name of the U.S. city. + api_key: OpenWeatherMap API key. + Returns: - float: Current temperature in Fahrenheit if successful. - None: If an error occurs or the data cannot be retrieved. + The current temperature in Fahrenheit as a float if successful, or None if an error occurs or data is unavailable. """ if not api_key or not isinstance(api_key, str): print("Error: Invalid or missing API key.") @@ -48,6 +46,11 @@ def get_temperature(city_name, api_key): return None def main(): + """ + Prompts the user for a U.S. city and displays its current temperature in Fahrenheit. + + Retrieves the OpenWeatherMap API key from the environment, requests the city name from the user, and prints the current temperature if available. Displays error messages for missing API key, empty city input, or failed data retrieval. + """ import os api_key = os.getenv('OPENWEATHER_API_KEY') if not api_key: