Late spring (May–June) and autumn (September–October) are the best times to visit. The weather is warm but not oppressive, the waterfront is lively, and the crowds have not reached their summer peak. July and August are hot and humid in the classic mid-Atlantic way; the city is busiest then, and the Chesapeake crab season is in full swing, which is either a reason to visit or a reason to avoid depending on your tolerance for crowds.
The Annapolis Boat Shows in October are a major event — the US Sailboat Show and the US Powerboat Show draw tens of thousands of visitors to the City Dock and are among the largest maritime shows in the country. If you are interested, book accommodation well in advance; if you are not, avoid that week.
Winter is quiet but pleasant for history-focused visits. The tourist crowds disappear, the colonial buildings look especially good in low light, and the Naval Academy's public events continue through the colder months.