| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This project has two sets of requirements:
Install with:
pip install -r requirements.txtInstall with:
pip install -r requirements-dev.txtIf you only install the minimum requirements, you can run the app but not run tests, lint, or format code.
A simple Python command-line app that fetches and displays the current weather for any city using the OpenWeatherMap API. You run it from the terminal and get the city name, temperature (Celsius), and weather description.
git clone <repository-url>
cd python-weather-cliThis project uses a .env file for the API key. You must set your OpenWeatherMap API key in this file.
cp .env.example .env
# Edit .env and set your key:
# OPENWEATHERMAP_API_KEY=your_api_key_herepython3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activateThis installs the package in "editable" mode, so code changes are immediately reflected:
pip install -e .
pip install -r requirements-dev.txtpip install .Run the app from the project root:
python -m weather_cli.main "London"
python -m weather_cli.main "New York"
python -m weather_cli.main "Tokyo"Or use the installed script:
weather "London"
weather "New York"
weather "Tokyo"You can use any city name. The app will print the current weather for that city.
You can see all available options with:
python -m weather_cli.main --helpOr:
weather --helpExample output:
usage: weather-cli [-h] [--debug] city Get current weather information for a city positional arguments: city Name of the city to get weather for options: -h, --help show this help message and exit --debug Enable debug logging
python-weather-cli/ ├── .env.example ├── README.md ├── requirements.txt ├── requirements-dev.txt ├── setup.py ├── pyproject.toml ├── src/ │ └── weather_cli/ │ ├── __init__.py │ ├── main.py │ ├── weather_service.py │ ├── weather_client.py │ ├── weather_data.py │ ├── config_util.py │ └── exceptions.py ├── tests/ └── docs/
Important: Activate the virtual environment first if you created one:
source venv/bin/activatepytestpytest --cov=weather_cli tests/black src testsflake8 src testsmypy srcThis project includes comprehensive unit tests covering all major components and functionality. The test suite ensures reliability, security, and proper error handling across the application.
Quick testing commands (remember to activate venv first: source venv/bin/activate):
The testing approach includes:
For detailed information about what is tested and how, see tests/TESTING.md.
To check code style:
flake8 src testsTo auto-format code:
black src testsTo type check:
mypy srcFor more details, see the code and comments in each file.
| Back | FazBrowse Home | New Git URL |